diff --git a/mozilla/l10n/tools/mozxlator/actions/AdvancedSearchAction.java b/mozilla/l10n/tools/mozxlator/actions/AdvancedSearchAction.java new file mode 100644 index 00000000000..e0dd6e3d2cd --- /dev/null +++ b/mozilla/l10n/tools/mozxlator/actions/AdvancedSearchAction.java @@ -0,0 +1,197 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MozillaTranslator (Mozilla Localization Tool) + * + * The Initial Developer of the Original Code is Henrik Lynggaard Hansen + * + * Portions created by Henrik Lynggard Hansen are + * Copyright (C) Henrik Lynggaard Hansen. + * All Rights Reserved. + * + * Contributor(s): + * Henrik Lynggaard Hansen (Initial Code) + * + */ +package org.mozilla.translator.actions; + +import java.awt.event.*; +import javax.swing.*; +import java.util.*; +import java.io.*; + + +import org.mozilla.translator.datamodel.*; +import org.mozilla.translator.gui.*; +import org.mozilla.translator.gui.dialog.*; +import org.mozilla.translator.gui.models.*; +import org.mozilla.translator.kernel.*; +import org.mozilla.translator.runners.*; +import org.mozilla.translator.fetch.*; +/** + * + * @author Henrik + * @version + */ +public class AdvancedSearchAction extends AbstractAction { + + private int rule; + private int column; + private String rul; + private String col; + private boolean cc; + + + /** Creates new SearchViewAction */ + public AdvancedSearchAction() + { + super("Advanced search",null); + } + + public void actionPerformed(ActionEvent evt) + { + Filter firstSearch,secondSearch,thirdSearch; + List collectedList; + String lname,text; + MainWindow mw = MainWindow.getDefaultInstance(); + AdvancedSearchDialog sd = new AdvancedSearchDialog(mw,true); + + + boolean okay = sd.visDialog(); + + if (okay) + { + + + if (sd.getFirstEnabled()) + { + rule= 0; + column =0; + rul = sd.getFirstRule(); + col = sd.getFirstColumn(); + lname = sd.getFirstLocaleName(); + text = sd.getFirstSearchText(); + cc = sd.getFirstCase(); + + assignRule(Filter.RULE_IS,"Is"); + assignRule(Filter.RULE_IS_NOT,"Is not"); + assignRule(Filter.RULE_CONTAINS,"Contains"); + assignRule(Filter.RULE_CONTAINS_NOT,"Doesn't contain"); + assignRule(Filter.RULE_STARTS_WITH,"Starts with"); + assignRule(Filter.RULE_ENDS_WITH,"Ends with"); + + assignColumn(Filter.FIELD_KEY,"Key"); + assignColumn(Filter.FIELD_NOTE,"Localization note"); + assignColumn(Filter.FIELD_ORG_TEXT,"Original text"); + assignColumn(Filter.FIELD_TRANS_TEXT,"Translated text"); + assignColumn(Filter.FIELD_COMMENT,"QA comment"); + + firstSearch = new Filter(rule,column,text,cc,lname); + + } + else + { + firstSearch =null; + } + + if (sd.getSecondEnabled()) + { + rule= 0; + column =0; + rul = sd.getSecondRule(); + col = sd.getSecondColumn(); + lname = sd.getSecondLocaleName(); + text = sd.getSecondSearchText(); + cc = sd.getSecondCase(); + + assignRule(Filter.RULE_IS,"Is"); + assignRule(Filter.RULE_IS_NOT,"Is not"); + assignRule(Filter.RULE_CONTAINS,"Contains"); + assignRule(Filter.RULE_CONTAINS_NOT,"Doesn't contain"); + assignRule(Filter.RULE_STARTS_WITH,"Starts with"); + assignRule(Filter.RULE_ENDS_WITH,"Ends with"); + + assignColumn(Filter.FIELD_KEY,"Key"); + assignColumn(Filter.FIELD_NOTE,"Localization note"); + assignColumn(Filter.FIELD_ORG_TEXT,"Original text"); + assignColumn(Filter.FIELD_TRANS_TEXT,"Translated text"); + assignColumn(Filter.FIELD_COMMENT,"QA comment"); + + + secondSearch = new Filter(rule,column,text,cc,lname); + } + else + { + secondSearch =null; + } + + + if (sd.getThirdEnabled()) + { + rule= 0; + column =0; + rul = sd.getThirdRule(); + col = sd.getThirdColumn(); + lname = sd.getThirdLocaleName(); + text = sd.getThirdSearchText(); + cc = sd.getThirdCase(); + + assignRule(Filter.RULE_IS,"Is"); + assignRule(Filter.RULE_IS_NOT,"Is not"); + assignRule(Filter.RULE_CONTAINS,"Contains"); + assignRule(Filter.RULE_CONTAINS_NOT,"Doesn't contain"); + assignRule(Filter.RULE_STARTS_WITH,"Starts with"); + assignRule(Filter.RULE_ENDS_WITH,"Ends with"); + + assignColumn(Filter.FIELD_KEY,"Key"); + assignColumn(Filter.FIELD_NOTE,"Localization note"); + assignColumn(Filter.FIELD_ORG_TEXT,"Original text"); + assignColumn(Filter.FIELD_TRANS_TEXT,"Translated text"); + assignColumn(Filter.FIELD_COMMENT,"QA comment"); + + thirdSearch = new Filter(rule,column,text,cc,lname); + } + else + { + thirdSearch =null; + } + + ShowWhatDialog swd = new ShowWhatDialog(); + swd.disableLocaleField(); + if (swd.visDialog()) + { + String localeName = swd.getSelectedLocale(); + List cols = swd.getSelectedColumns(); + Fetcher sf= new FetchAdvancedSearch(firstSearch,secondSearch,thirdSearch,true); + collectedList = FetchRunner.getFromGlossary(sf); + Collections.sort(collectedList); + ComplexTableWindow ctw = new ComplexTableWindow("Found Strings",collectedList,cols,localeName); + } + } + } + + private void assignRule(int value,String comp) + { + if (rul.equals(comp)) + { + rule = value; + } + } + + private void assignColumn(int value,String comp) + { + if (col.equals(comp)) + { + column = value; + } + } + +} \ No newline at end of file diff --git a/mozilla/l10n/tools/mozxlator/actions/ImportLocaleAction.java b/mozilla/l10n/tools/mozxlator/actions/ImportLocaleAction.java new file mode 100644 index 00000000000..decf959d991 --- /dev/null +++ b/mozilla/l10n/tools/mozxlator/actions/ImportLocaleAction.java @@ -0,0 +1,59 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MozillaTranslator (Mozilla Localization Tool) + * + * The Initial Developer of the Original Code is Henrik Lynggaard Hansen + * + * Portions created by Henrik Lynggard Hansen are + * Copyright (C) Henrik Lynggaard Hansen. + * All Rights Reserved. + * + * Contributor(s): + * Henrik Lynggaard Hansen (Initial Code) + * + */ +package org.mozilla.translator.actions; + +import java.awt.event.*; +import javax.swing.*; + +import org.mozilla.translator.datamodel.*; +import org.mozilla.translator.runners.*; +import org.mozilla.translator.gui.dialog.*; +/** + * + * @author Henrik Lynggaard Hansen + * @version + */ +public class ImportLocaleAction extends AbstractAction { + + /** Creates new InstallManagerAction */ + public ImportLocaleAction() + { + super("Import locale from chrome",null); + } + + public void actionPerformed(ActionEvent evt) + { + + ReadLocaleDialog ig = new ReadLocaleDialog(); + boolean result; + + result = ig.visDialog(); + + if (result) + { + ImportLocaleRunner ior = new ImportLocaleRunner(ig.getInstall(),ig.getFile(),ig.getLocaleName()); + ior.start(); + } + } +} \ No newline at end of file diff --git a/mozilla/l10n/tools/mozxlator/actions/SearchViewAction.java b/mozilla/l10n/tools/mozxlator/actions/SearchViewAction.java index e28b2585ae6..098a7261614 100644 --- a/mozilla/l10n/tools/mozxlator/actions/SearchViewAction.java +++ b/mozilla/l10n/tools/mozxlator/actions/SearchViewAction.java @@ -53,7 +53,7 @@ public class SearchViewAction extends AbstractAction { /** Creates new SearchViewAction */ public SearchViewAction() { - super("Search entries",null); + super("Simple Search",null); } public void actionPerformed(ActionEvent evt) @@ -92,7 +92,7 @@ public class SearchViewAction extends AbstractAction { - Filter search = new Filter(rule,column,text,cc); + Filter search = new Filter(rule,column,text,cc,lname); ShowWhatDialog swd = new ShowWhatDialog(); @@ -101,7 +101,7 @@ public class SearchViewAction extends AbstractAction { { String localeName = swd.getSelectedLocale(); List cols = swd.getSelectedColumns(); - Fetcher sf= new FetchSearch(localeName,search); + Fetcher sf= new FetchSearch(search); collectedList = FetchRunner.getFromGlossary(sf); Collections.sort(collectedList); ComplexTableWindow ctw = new ComplexTableWindow("Found Strings",collectedList,cols,localeName); diff --git a/mozilla/l10n/tools/mozxlator/compile.cmd.txt b/mozilla/l10n/tools/mozxlator/compile.cmd.txt new file mode 100644 index 00000000000..d33d9fb1a13 --- /dev/null +++ b/mozilla/l10n/tools/mozxlator/compile.cmd.txt @@ -0,0 +1 @@ +javac diff --git a/mozilla/l10n/tools/mozxlator/datamodel/Filter.java b/mozilla/l10n/tools/mozxlator/datamodel/Filter.java index 94f07b7bb06..0c13924a683 100644 --- a/mozilla/l10n/tools/mozxlator/datamodel/Filter.java +++ b/mozilla/l10n/tools/mozxlator/datamodel/Filter.java @@ -46,17 +46,18 @@ public class Filter extends Object { private int rule; private int field; - private int attribute1; private boolean caseCheck; private String value; + private String localeName; /** Creates new Filter */ - public Filter(int r,int f,String v,boolean cc) + public Filter(int r,int f,String v,boolean cc,String ln) { rule= r; field=f; value=v; caseCheck=cc; + localeName=ln; } public int getRule() @@ -89,12 +90,18 @@ public class Filter extends Object { value=v; } - public boolean check(Phrase phrase) + public String toString() { - return check(phrase,"MT_no_locale"); + String result; + result= "Rule : "+ rule + "\n"; + result = result + "Field : "+ field + "\n"; + result = result + "value : "+ value + "\n"; + result = result + "case : " + caseCheck + "\n"; + result = result + "locale : " + localeName + "\n"; + return result; } - public boolean check(Phrase phrase,String localeName) + public boolean check(Phrase phrase) { boolean result; String compareText; @@ -156,7 +163,7 @@ public class Filter extends Object { } break; case RULE_CONTAINS_NOT: - if (compareText.indexOf(value)!=-1) + if (compareText.indexOf(value)==-1) { result=true; } diff --git a/mozilla/l10n/tools/mozxlator/datamodel/FilterList.java b/mozilla/l10n/tools/mozxlator/datamodel/FilterList.java index fe8c1ba161e..161ba4592be 100644 --- a/mozilla/l10n/tools/mozxlator/datamodel/FilterList.java +++ b/mozilla/l10n/tools/mozxlator/datamodel/FilterList.java @@ -75,11 +75,6 @@ public class FilterList extends AbstractListModel { } public boolean check(Phrase phrase) - { - return check(phrase, "MT_no_locale"); - } - - public boolean check(Phrase phrase,String localeName) { Filter f; Iterator i = filters.iterator(); @@ -89,7 +84,7 @@ public class FilterList extends AbstractListModel { { f = (Filter) i.next(); - result = f.check(phrase,localeName); + result = f.check(phrase); } return result; } diff --git a/mozilla/l10n/tools/mozxlator/fetch/FetchAdvancedSearch.java b/mozilla/l10n/tools/mozxlator/fetch/FetchAdvancedSearch.java new file mode 100644 index 00000000000..d75011bb2ca --- /dev/null +++ b/mozilla/l10n/tools/mozxlator/fetch/FetchAdvancedSearch.java @@ -0,0 +1,118 @@ +/* + * FetchUntranslated.java + * + * Created on 19. august 2000, 20:32 + */ + +package org.mozilla.translator.fetch; + +import org.mozilla.translator.datamodel.*; + + +/** + * + * @author Henrik Lynggaard + * @version + */ +public class FetchAdvancedSearch implements Fetcher +{ + + private Filter first; + private Filter second; + private Filter third; + private boolean all; + + /** Creates new FetchUntranslated */ + public FetchAdvancedSearch(Filter f1,Filter f2,Filter f3,boolean al) + { + first = f1; + second = f2; + third = f3; + all=al; + + } + + public boolean check(Phrase ph) + { + boolean realResult,firstResult,secondResult,thirdResult; + + if (all) + { + if (first!=null) + { + firstResult = first.check(ph); + } + else + { + firstResult=true; + } + + if (second!=null) + { + secondResult = second.check(ph); + } + else + { + secondResult=true; + } + + if (third!=null) + { + thirdResult = third.check(ph); + } + else + { + thirdResult=true; + } + + if ((firstResult==true) && (secondResult==true) && (thirdResult==true)) + { + realResult=true; + } + else + { + realResult=false; + } + } + else + { + if (first!=null) + { + firstResult = first.check(ph); + } + else + { + firstResult=false; + } + + if (second!=null) + { + secondResult = second.check(ph); + } + else + { + secondResult=false; + } + + if (third!=null) + { + thirdResult = third.check(ph); + } + else + { + thirdResult=false; + } + + if ((firstResult==true) || (secondResult==true) || (thirdResult==true)) + { + realResult=true; + } + else + { + realResult=false; + } + } + return realResult; + + } +} \ No newline at end of file diff --git a/mozilla/l10n/tools/mozxlator/fetch/FetchSearch.java b/mozilla/l10n/tools/mozxlator/fetch/FetchSearch.java index 417052a2239..95c8da68352 100644 --- a/mozilla/l10n/tools/mozxlator/fetch/FetchSearch.java +++ b/mozilla/l10n/tools/mozxlator/fetch/FetchSearch.java @@ -17,18 +17,16 @@ import org.mozilla.translator.datamodel.*; public class FetchSearch implements Fetcher { - private String localeName; private Filter filt; /** Creates new FetchUntranslated */ - public FetchSearch(String ln,Filter f) + public FetchSearch(Filter f) { - localeName = ln; filt=f; } public boolean check(Phrase ph) { - return filt.check(ph,localeName); + return filt.check(ph); } } \ No newline at end of file diff --git a/mozilla/l10n/tools/mozxlator/gui/MainWindow.java b/mozilla/l10n/tools/mozxlator/gui/MainWindow.java index f7f471961bc..9541f59231e 100644 --- a/mozilla/l10n/tools/mozxlator/gui/MainWindow.java +++ b/mozilla/l10n/tools/mozxlator/gui/MainWindow.java @@ -91,7 +91,8 @@ public class MainWindow extends JFrame { glossaryMenu.addSeparator(); addMenuItem(glossaryMenu , new ImportPartialGlossaryAction(), "control shift I"); addMenuItem(glossaryMenu , new ExportPartialGlossaryAction(), "control shift E"); -// glossaryMenu.addSeparator(); + glossaryMenu.addSeparator(); + addMenuItem(glossaryMenu , new ImportLocaleAction(),""); // addMenuItem(glossaryMenu , new NoOpAction("ImportMozExpAction()"), ""); // addMenuItem(glossaryMenu , new NoOpAction("ExportMozExpAction()"), ""); glossaryMenu.addSeparator(); @@ -118,6 +119,8 @@ public class MainWindow extends JFrame { addMenuItem(viewMenu , new RedundantViewAction(), "alt R"); addMenuItem(viewMenu , new KeepViewAction(), "alt K"); addMenuItem(viewMenu , new SearchViewAction(), "alt S"); + addMenuItem(viewMenu , new AdvancedSearchAction() , ""); + menuBar.add(viewMenu); diff --git a/mozilla/l10n/tools/mozxlator/gui/dialog/AdvancedSearchDialog.java b/mozilla/l10n/tools/mozxlator/gui/dialog/AdvancedSearchDialog.java index c93acd57188..f95086eca82 100644 --- a/mozilla/l10n/tools/mozxlator/gui/dialog/AdvancedSearchDialog.java +++ b/mozilla/l10n/tools/mozxlator/gui/dialog/AdvancedSearchDialog.java @@ -6,6 +6,10 @@ package org.mozilla.translator.gui.dialog; +import javax.swing.*; +import org.mozilla.translator.kernel.*; +import org.mozilla.translator.datamodel.*; + /** * * @author Henrik Lynggaard @@ -13,11 +17,15 @@ package org.mozilla.translator.gui.dialog; */ public class AdvancedSearchDialog extends javax.swing.JDialog { + private boolean okay; + private boolean all; + /** Creates new form AdvancedSearchDialog */ public AdvancedSearchDialog(java.awt.Frame parent,boolean modal) { super (parent, modal); initComponents (); pack (); + Utils.placeFrameAtCenter(this); } /** This method is called from within the constructor to @@ -25,235 +33,476 @@ public class AdvancedSearchDialog extends javax.swing.JDialog { * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the FormEditor. */ -private void initComponents() {//GEN-BEGIN:initComponents -jLabel1 = new javax.swing.JLabel(); -jLabel2 = new javax.swing.JLabel(); -jLabel3 = new javax.swing.JLabel(); -jLabel4 = new javax.swing.JLabel(); -jComboBox1 = new javax.swing.JComboBox(); -jComboBox2 = new javax.swing.JComboBox(); -jTextField1 = new javax.swing.JTextField(); -jTextField2 = new javax.swing.JTextField(); -jCheckBox1 = new javax.swing.JCheckBox(); -jCheckBox2 = new javax.swing.JCheckBox(); -jComboBox3 = new javax.swing.JComboBox(); -jComboBox4 = new javax.swing.JComboBox(); -jTextField3 = new javax.swing.JTextField(); -jTextField4 = new javax.swing.JTextField(); -jCheckBox3 = new javax.swing.JCheckBox(); -jComboBox5 = new javax.swing.JComboBox(); -jComboBox6 = new javax.swing.JComboBox(); -jTextField5 = new javax.swing.JTextField(); -jTextField6 = new javax.swing.JTextField(); -jPanel1 = new javax.swing.JPanel(); -jButton1 = new javax.swing.JButton(); -jButton2 = new javax.swing.JButton(); -getContentPane().setLayout(new java.awt.GridBagLayout()); -java.awt.GridBagConstraints gridBagConstraints1; -addWindowListener(new java.awt.event.WindowAdapter() { -public void windowClosing(java.awt.event.WindowEvent evt) { -closeDialog(evt); -} -} -); + private void initComponents() {//GEN-BEGIN:initComponents + fieldLabel = new javax.swing.JLabel(); + ruleLabel = new javax.swing.JLabel(); + textLabel = new javax.swing.JLabel(); + localeLabel = new javax.swing.JLabel(); + firstField = new javax.swing.JComboBox(); + firstRule = new javax.swing.JComboBox(); + firstText = new javax.swing.JTextField(); + firstLocale = new javax.swing.JTextField(); + firstEnable = new javax.swing.JCheckBox(); + secondEnable = new javax.swing.JCheckBox(); + secondField = new javax.swing.JComboBox(); + secondRule = new javax.swing.JComboBox(); + secondText = new javax.swing.JTextField(); + secondLocale = new javax.swing.JTextField(); + thirdEnable = new javax.swing.JCheckBox(); + thirdField = new javax.swing.JComboBox(); + thirdRule = new javax.swing.JComboBox(); + thirdText = new javax.swing.JTextField(); + thirdLocale = new javax.swing.JTextField(); + jPanel1 = new javax.swing.JPanel(); + anyButton = new javax.swing.JButton(); + allButton = new javax.swing.JButton(); + cancelButton = new javax.swing.JButton(); + caseLabel = new javax.swing.JLabel(); + firstCase = new javax.swing.JCheckBox(); + secondCase = new javax.swing.JCheckBox(); + thirdCase = new javax.swing.JCheckBox(); + getContentPane().setLayout(new java.awt.GridBagLayout()); + java.awt.GridBagConstraints gridBagConstraints1; + setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + closeDialog(evt); + } + } + ); + + fieldLabel.setText("Field"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 1; + gridBagConstraints1.gridy = 0; + gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; + getContentPane().add(fieldLabel, gridBagConstraints1); + + + ruleLabel.setText("Rule "); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 2; + gridBagConstraints1.gridy = 0; + gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; + getContentPane().add(ruleLabel, gridBagConstraints1); + + + textLabel.setText("text"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 3; + gridBagConstraints1.gridy = 0; + gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; + getContentPane().add(textLabel, gridBagConstraints1); + + + localeLabel.setText("locale"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 4; + gridBagConstraints1.gridy = 0; + gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; + getContentPane().add(localeLabel, gridBagConstraints1); + + + firstField.addItem("Key"); + firstField.addItem("Localization note"); + firstField.addItem("Original text"); + firstField.addItem("Translated text"); + firstField.addItem("QA comment"); + + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 1; + gridBagConstraints1.gridy = 1; + getContentPane().add(firstField, gridBagConstraints1); + + + firstRule.addItem("Is"); + firstRule.addItem("Is not"); + firstRule.addItem("Contains"); + firstRule.addItem("Doesn't contain"); + firstRule.addItem("Starts with"); + firstRule.addItem("Ends with"); + + + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 2; + gridBagConstraints1.gridy = 1; + getContentPane().add(firstRule, gridBagConstraints1); + + + firstText.setColumns(15); + firstText.setText("empty"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 3; + gridBagConstraints1.gridy = 1; + getContentPane().add(firstText, gridBagConstraints1); + + + firstLocale.setColumns(10); + firstLocale.setText("empty"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 4; + gridBagConstraints1.gridy = 1; + getContentPane().add(firstLocale, gridBagConstraints1); + + + firstEnable.setText("Enabled"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 0; + gridBagConstraints1.gridy = 1; + getContentPane().add(firstEnable, gridBagConstraints1); + + + secondEnable.setText("Enabled"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 0; + gridBagConstraints1.gridy = 2; + getContentPane().add(secondEnable, gridBagConstraints1); + + + secondField.addItem("Key"); + secondField.addItem("Localization note"); + secondField.addItem("Original text"); + secondField.addItem("Translated text"); + secondField.addItem("QA comment"); + + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 1; + gridBagConstraints1.gridy = 2; + getContentPane().add(secondField, gridBagConstraints1); + + + secondRule.addItem("Is"); + secondRule.addItem("Is not"); + secondRule.addItem("Contains"); + secondRule.addItem("Doesn't contain"); + secondRule.addItem("Starts with"); + secondRule.addItem("Ends with"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 2; + gridBagConstraints1.gridy = 2; + getContentPane().add(secondRule, gridBagConstraints1); + + + secondText.setColumns(15); + secondText.setText("empty"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 3; + gridBagConstraints1.gridy = 2; + getContentPane().add(secondText, gridBagConstraints1); + + + secondLocale.setColumns(10); + secondLocale.setText("empty"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 4; + gridBagConstraints1.gridy = 2; + getContentPane().add(secondLocale, gridBagConstraints1); + + + thirdEnable.setText("Enabled"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 0; + gridBagConstraints1.gridy = 3; + getContentPane().add(thirdEnable, gridBagConstraints1); + + + thirdField.addItem("Key"); + thirdField.addItem("Localization note"); + thirdField.addItem("Original text"); + thirdField.addItem("Translated text"); + thirdField.addItem("QA comment"); + + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 1; + gridBagConstraints1.gridy = 3; + getContentPane().add(thirdField, gridBagConstraints1); + + + thirdRule.addItem("Is"); + thirdRule.addItem("Is not"); + thirdRule.addItem("Contains"); + thirdRule.addItem("Doesn't contain"); + thirdRule.addItem("Starts with"); + thirdRule.addItem("Ends with"); + + + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 2; + gridBagConstraints1.gridy = 3; + getContentPane().add(thirdRule, gridBagConstraints1); + + + thirdText.setColumns(15); + thirdText.setText("empty"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 3; + gridBagConstraints1.gridy = 3; + getContentPane().add(thirdText, gridBagConstraints1); + + + thirdLocale.setColumns(10); + thirdLocale.setText("empty"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 4; + gridBagConstraints1.gridy = 3; + getContentPane().add(thirdLocale, gridBagConstraints1); + + + + anyButton.setText("Any of the above"); + anyButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + anyButtonPressed(evt); + } + } + ); + jPanel1.add(anyButton); + + + allButton.setText("All of the above"); + allButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + allButtonPressed(evt); + } + } + ); + jPanel1.add(allButton); + + + cancelButton.setText("Cancel"); + cancelButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cancelButtonPressed(evt); + } + } + ); + jPanel1.add(cancelButton); + + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 0; + gridBagConstraints1.gridy = 4; + gridBagConstraints1.gridwidth = 0; + gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; + getContentPane().add(jPanel1, gridBagConstraints1); + + + caseLabel.setText("Casesentitive"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 5; + gridBagConstraints1.gridy = 0; + gridBagConstraints1.gridwidth = 0; + gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; + getContentPane().add(caseLabel, gridBagConstraints1); + + + firstCase.setLabel("yes"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 5; + gridBagConstraints1.gridy = 1; + gridBagConstraints1.gridwidth = 0; + getContentPane().add(firstCase, gridBagConstraints1); + + + secondCase.setLabel("yes"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 5; + gridBagConstraints1.gridy = 2; + gridBagConstraints1.gridwidth = 0; + getContentPane().add(secondCase, gridBagConstraints1); + + + thirdCase.setLabel("yes"); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 5; + gridBagConstraints1.gridy = 3; + gridBagConstraints1.gridwidth = 0; + getContentPane().add(thirdCase, gridBagConstraints1); + + }//GEN-END:initComponents -jLabel1.setText("Field"); + private void cancelButtonPressed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonPressed + all=false; + okay=false; + setVisible(false); + }//GEN-LAST:event_cancelButtonPressed -gridBagConstraints1 = new java.awt.GridBagConstraints(); -gridBagConstraints1.gridx = 1; -gridBagConstraints1.gridy = 0; -gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; -getContentPane().add(jLabel1, gridBagConstraints1); + private void allButtonPressed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allButtonPressed + all=true; + okay=true; + setVisible(false); + + }//GEN-LAST:event_allButtonPressed - -jLabel2.setText("Rule "); - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -gridBagConstraints1.gridx = 2; -gridBagConstraints1.gridy = 0; -gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; -getContentPane().add(jLabel2, gridBagConstraints1); - - -jLabel3.setText("text"); - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -gridBagConstraints1.gridx = 3; -gridBagConstraints1.gridy = 0; -gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; -getContentPane().add(jLabel3, gridBagConstraints1); - - -jLabel4.setText("locale"); - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -gridBagConstraints1.gridx = 4; -gridBagConstraints1.gridy = 0; -gridBagConstraints1.gridwidth = 0; -gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; -getContentPane().add(jLabel4, gridBagConstraints1); - - - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -gridBagConstraints1.gridx = 1; -gridBagConstraints1.gridy = 1; -getContentPane().add(jComboBox1, gridBagConstraints1); - - - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -gridBagConstraints1.gridx = 2; -gridBagConstraints1.gridy = 1; -getContentPane().add(jComboBox2, gridBagConstraints1); - - -jTextField1.setText("jTextField1"); - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -gridBagConstraints1.gridx = 3; -gridBagConstraints1.gridy = 1; -getContentPane().add(jTextField1, gridBagConstraints1); - - -jTextField2.setText("jTextField2"); - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -gridBagConstraints1.gridx = 4; -gridBagConstraints1.gridy = 1; -gridBagConstraints1.gridwidth = 0; -getContentPane().add(jTextField2, gridBagConstraints1); - - -jCheckBox1.setText("jCheckBox1"); - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -gridBagConstraints1.gridx = 0; -gridBagConstraints1.gridy = 1; -getContentPane().add(jCheckBox1, gridBagConstraints1); - - -jCheckBox2.setText("jCheckBox2"); - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -gridBagConstraints1.gridx = 0; -gridBagConstraints1.gridy = 2; -getContentPane().add(jCheckBox2, gridBagConstraints1); - - - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -gridBagConstraints1.gridx = 1; -gridBagConstraints1.gridy = 2; -getContentPane().add(jComboBox3, gridBagConstraints1); - - - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -gridBagConstraints1.gridx = 2; -gridBagConstraints1.gridy = 2; -getContentPane().add(jComboBox4, gridBagConstraints1); - - -jTextField3.setText("jTextField3"); - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -gridBagConstraints1.gridx = 3; -gridBagConstraints1.gridy = 2; -getContentPane().add(jTextField3, gridBagConstraints1); - - -jTextField4.setText("jTextField4"); - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -gridBagConstraints1.gridx = 4; -gridBagConstraints1.gridy = 2; -gridBagConstraints1.gridwidth = 0; -getContentPane().add(jTextField4, gridBagConstraints1); - - -jCheckBox3.setText("jCheckBox3"); - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -getContentPane().add(jCheckBox3, gridBagConstraints1); - - - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -getContentPane().add(jComboBox5, gridBagConstraints1); - - - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -getContentPane().add(jComboBox6, gridBagConstraints1); - - -jTextField5.setText("jTextField5"); - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -getContentPane().add(jTextField5, gridBagConstraints1); - - -jTextField6.setText("jTextField6"); - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -gridBagConstraints1.gridwidth = 0; -getContentPane().add(jTextField6, gridBagConstraints1); - - - -jButton1.setText("jButton1"); - jPanel1.add(jButton1); - - -jButton2.setText("jButton2"); - jPanel1.add(jButton2); - - -gridBagConstraints1 = new java.awt.GridBagConstraints(); -gridBagConstraints1.gridwidth = 0; -gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; -getContentPane().add(jPanel1, gridBagConstraints1); - -}//GEN-END:initComponents + private void anyButtonPressed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_anyButtonPressed + all=false; + okay=true; + setVisible(false); + + }//GEN-LAST:event_anyButtonPressed /** Closes the dialog */ private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog + okay=false; setVisible (false); - dispose (); + }//GEN-LAST:event_closeDialog - /** - * @param args the command line arguments - */ - public static void main (String args[]) { - new AdvancedSearchDialog (new javax.swing.JFrame (), true).show (); + public boolean getFirstEnabled() + { + return firstEnable.isSelected(); } + public boolean getSecondEnabled() + { + return secondEnable.isSelected(); + } + public boolean getThirdEnabled() + { + return thirdEnable.isSelected(); + } + + public String getFirstColumn() + { + return firstField.getSelectedItem().toString(); + } + + public String getSecondColumn() + { + return secondField.getSelectedItem().toString(); + } -// Variables declaration - do not modify//GEN-BEGIN:variables -private javax.swing.JLabel jLabel1; -private javax.swing.JLabel jLabel2; -private javax.swing.JLabel jLabel3; -private javax.swing.JLabel jLabel4; -private javax.swing.JComboBox jComboBox1; -private javax.swing.JComboBox jComboBox2; -private javax.swing.JTextField jTextField1; -private javax.swing.JTextField jTextField2; -private javax.swing.JCheckBox jCheckBox1; -private javax.swing.JCheckBox jCheckBox2; -private javax.swing.JComboBox jComboBox3; -private javax.swing.JComboBox jComboBox4; -private javax.swing.JTextField jTextField3; -private javax.swing.JTextField jTextField4; -private javax.swing.JCheckBox jCheckBox3; -private javax.swing.JComboBox jComboBox5; -private javax.swing.JComboBox jComboBox6; -private javax.swing.JTextField jTextField5; -private javax.swing.JTextField jTextField6; -private javax.swing.JPanel jPanel1; -private javax.swing.JButton jButton1; -private javax.swing.JButton jButton2; -// End of variables declaration//GEN-END:variables + public String getThirdColumn() + { + return thirdField.getSelectedItem().toString(); + } + + public String getFirstRule() + { + return firstRule.getSelectedItem().toString(); + } + + public String getSecondRule() + { + return secondRule.getSelectedItem().toString(); + } + + public String getThirdRule() + { + return secondRule.getSelectedItem().toString(); + } + + public String getFirstSearchText() + { + return firstText.getText(); + } + + public String getSecondSearchText() + { + return secondText.getText(); + } + + public String getThirdSearchText() + { + return thirdText.getText(); + } + + public String getFirstLocaleName() + { + return firstLocale.getText(); + } + + public String getSecondLocaleName() + { + return secondLocale.getText(); + } + + public String getThirdLocaleName() + { + return thirdLocale.getText(); + } + + public boolean getFirstCase() + { + return firstCase.isSelected(); + } + public boolean getSecondCase() + { + return secondCase.isSelected(); + } + + public boolean getThirdCase() + { + return thirdCase.isSelected(); + } + + public boolean getAllChoice() + { + return all; + } + public boolean visDialog() + { + // here should state remembering go + okay=false; + setVisible(true); + + //if (okay) + //{ + // remember state + //} + return okay; + } + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel fieldLabel; + private javax.swing.JLabel ruleLabel; + private javax.swing.JLabel textLabel; + private javax.swing.JLabel localeLabel; + private javax.swing.JComboBox firstField; + private javax.swing.JComboBox firstRule; + private javax.swing.JTextField firstText; + private javax.swing.JTextField firstLocale; + private javax.swing.JCheckBox firstEnable; + private javax.swing.JCheckBox secondEnable; + private javax.swing.JComboBox secondField; + private javax.swing.JComboBox secondRule; + private javax.swing.JTextField secondText; + private javax.swing.JTextField secondLocale; + private javax.swing.JCheckBox thirdEnable; + private javax.swing.JComboBox thirdField; + private javax.swing.JComboBox thirdRule; + private javax.swing.JTextField thirdText; + private javax.swing.JTextField thirdLocale; + private javax.swing.JPanel jPanel1; + private javax.swing.JButton anyButton; + private javax.swing.JButton allButton; + private javax.swing.JButton cancelButton; + private javax.swing.JLabel caseLabel; + private javax.swing.JCheckBox firstCase; + private javax.swing.JCheckBox secondCase; + private javax.swing.JCheckBox thirdCase; + // End of variables declaration//GEN-END:variables } diff --git a/mozilla/l10n/tools/mozxlator/gui/dialog/EditInstallDialog.java b/mozilla/l10n/tools/mozxlator/gui/dialog/EditInstallDialog.java index 4b8d9048920..b0a8c57bad5 100644 --- a/mozilla/l10n/tools/mozxlator/gui/dialog/EditInstallDialog.java +++ b/mozilla/l10n/tools/mozxlator/gui/dialog/EditInstallDialog.java @@ -93,7 +93,7 @@ public class EditInstallDialog extends javax.swing.JDialog { infoPanel.add(nameField, gridBagConstraints2); - pathLabel.setText("Path"); + pathLabel.setText("Location"); gridBagConstraints2 = new java.awt.GridBagConstraints(); gridBagConstraints2.gridx = 0; gridBagConstraints2.gridy = 1; @@ -112,7 +112,8 @@ public class EditInstallDialog extends javax.swing.JDialog { infoPanel.add(pathField, gridBagConstraints2); - pathButton.setText("Choose"); + pathButton.setToolTipText("Choose directory or jar file for the install"); + pathButton.setText("Choose"); pathButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { pathButtonPressed(evt); @@ -183,7 +184,7 @@ public class EditInstallDialog extends javax.swing.JDialog { File defaultFile = new File(pathField.getText()); JFileChooser dirChooser = new JFileChooser(); dirChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - dirChooser.setDialogTitle("Select directory for the install"); + dirChooser.setDialogTitle("Select directory or jar file for the install"); dirChooser.setSelectedFile(defaultFile); int result = dirChooser.showDialog(this,"Choose"); if (result==JFileChooser.APPROVE_OPTION) diff --git a/mozilla/l10n/tools/mozxlator/gui/dialog/ImportGlossaryDialog.java b/mozilla/l10n/tools/mozxlator/gui/dialog/ImportGlossaryDialog.java index fd4d0fbdc17..607a0f7cfa5 100644 --- a/mozilla/l10n/tools/mozxlator/gui/dialog/ImportGlossaryDialog.java +++ b/mozilla/l10n/tools/mozxlator/gui/dialog/ImportGlossaryDialog.java @@ -53,114 +53,113 @@ public class ImportGlossaryDialog extends javax.swing.JDialog { * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the FormEditor. */ - private void initComponents () {//GEN-BEGIN:initComponents - infPanel = new javax.swing.JPanel (); - fileLabel = new javax.swing.JLabel (); - fileField = new javax.swing.JTextField (); - fileButton = new javax.swing.JButton (); - installLabel = new javax.swing.JLabel (); + private void initComponents() {//GEN-BEGIN:initComponents + infPanel = new javax.swing.JPanel(); + fileLabel = new javax.swing.JLabel(); + fileField = new javax.swing.JTextField(); + fileButton = new javax.swing.JButton(); + installLabel = new javax.swing.JLabel(); installCombo = new JComboBox(Glossary.getDefaultInstance().toArray()); - okButton = new javax.swing.JButton (); - cancelButton = new javax.swing.JButton (); - getContentPane ().setLayout (new java.awt.GridBagLayout ()); + okButton = new javax.swing.JButton(); + cancelButton = new javax.swing.JButton(); + getContentPane().setLayout(new java.awt.GridBagLayout()); java.awt.GridBagConstraints gridBagConstraints1; - setDefaultCloseOperation (javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); - - infPanel.setLayout (new java.awt.GridBagLayout ()); + setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); + + infPanel.setLayout(new java.awt.GridBagLayout()); java.awt.GridBagConstraints gridBagConstraints2; - infPanel.setBorder (new javax.swing.border.TitledBorder( + infPanel.setBorder(new javax.swing.border.TitledBorder( new javax.swing.border.EtchedBorder(), "Information", 4, 2, new java.awt.Font ("Dialog", 0, 10))); - - fileLabel.setText ("Glossary file"); - - gridBagConstraints2 = new java.awt.GridBagConstraints (); - gridBagConstraints2.insets = new java.awt.Insets (3, 3, 3, 3); + + fileLabel.setText("Glossary file"); + gridBagConstraints2 = new java.awt.GridBagConstraints(); + gridBagConstraints2.insets = new java.awt.Insets(3, 3, 3, 3); gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST; - infPanel.add (fileLabel, gridBagConstraints2); - - fileField.setColumns (20); - fileField.setText ("D:\\preo\\fhbndj\\hoigtrod\\glossary.zip"); - - gridBagConstraints2 = new java.awt.GridBagConstraints (); - gridBagConstraints2.insets = new java.awt.Insets (3, 0, 3, 0); + infPanel.add(fileLabel, gridBagConstraints2); + + + fileField.setColumns(20); + fileField.setText("D:\\preo\\fhbndj\\hoigtrod\\glossary.zip"); + gridBagConstraints2 = new java.awt.GridBagConstraints(); + gridBagConstraints2.insets = new java.awt.Insets(3, 0, 3, 0); gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST; - infPanel.add (fileField, gridBagConstraints2); - - fileButton.setText ("Choose"); - fileButton.addActionListener (new java.awt.event.ActionListener () { - public void actionPerformed (java.awt.event.ActionEvent evt) { - fileButtonPressed (evt); + infPanel.add(fileField, gridBagConstraints2); + + + fileButton.setText("Choose"); + fileButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + fileButtonPressed(evt); } } ); - - gridBagConstraints2 = new java.awt.GridBagConstraints (); + gridBagConstraints2 = new java.awt.GridBagConstraints(); gridBagConstraints2.gridwidth = 0; - gridBagConstraints2.insets = new java.awt.Insets (3, 0, 3, 3); + gridBagConstraints2.insets = new java.awt.Insets(3, 0, 3, 3); gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST; - infPanel.add (fileButton, gridBagConstraints2); - - installLabel.setText ("Install"); - - gridBagConstraints2 = new java.awt.GridBagConstraints (); + infPanel.add(fileButton, gridBagConstraints2); + + + installLabel.setText("Install"); + gridBagConstraints2 = new java.awt.GridBagConstraints(); gridBagConstraints2.gridx = 0; gridBagConstraints2.gridy = 1; - gridBagConstraints2.insets = new java.awt.Insets (0, 3, 3, 3); + gridBagConstraints2.insets = new java.awt.Insets(0, 3, 3, 3); gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST; - infPanel.add (installLabel, gridBagConstraints2); - - - gridBagConstraints2 = new java.awt.GridBagConstraints (); + infPanel.add(installLabel, gridBagConstraints2); + + + gridBagConstraints2 = new java.awt.GridBagConstraints(); gridBagConstraints2.gridx = 1; gridBagConstraints2.gridy = 1; gridBagConstraints2.gridwidth = 0; gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL; - gridBagConstraints2.insets = new java.awt.Insets (0, 0, 3, 3); + gridBagConstraints2.insets = new java.awt.Insets(0, 0, 3, 3); gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST; - infPanel.add (installCombo, gridBagConstraints2); - - - gridBagConstraints1 = new java.awt.GridBagConstraints (); + infPanel.add(installCombo, gridBagConstraints2); + + + gridBagConstraints1 = new java.awt.GridBagConstraints(); gridBagConstraints1.gridwidth = 0; - gridBagConstraints1.insets = new java.awt.Insets (3, 3, 3, 3); - getContentPane ().add (infPanel, gridBagConstraints1); - - okButton.setText ("OK"); - okButton.addActionListener (new java.awt.event.ActionListener () { - public void actionPerformed (java.awt.event.ActionEvent evt) { - okButtonPressed (evt); + gridBagConstraints1.insets = new java.awt.Insets(3, 3, 3, 3); + getContentPane().add(infPanel, gridBagConstraints1); + + + okButton.setText("OK"); + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + okButtonPressed(evt); } } ); - - - gridBagConstraints1 = new java.awt.GridBagConstraints (); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); gridBagConstraints1.gridx = 0; gridBagConstraints1.gridy = 1; - gridBagConstraints1.insets = new java.awt.Insets (0, 3, 3, 3); + gridBagConstraints1.insets = new java.awt.Insets(0, 3, 3, 3); gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints1.weightx = 0.5; - getContentPane ().add (okButton, gridBagConstraints1); - - cancelButton.setText ("Cancel"); - cancelButton.addActionListener (new java.awt.event.ActionListener () { - public void actionPerformed (java.awt.event.ActionEvent evt) { - cancelButtonPressed (evt); + getContentPane().add(okButton, gridBagConstraints1); + + + cancelButton.setText("Cancel"); + cancelButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cancelButtonPressed(evt); } } ); - - - gridBagConstraints1 = new java.awt.GridBagConstraints (); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); gridBagConstraints1.gridx = 1; gridBagConstraints1.gridy = 1; gridBagConstraints1.gridwidth = 0; - gridBagConstraints1.insets = new java.awt.Insets (0, 0, 3, 3); + gridBagConstraints1.insets = new java.awt.Insets(0, 0, 3, 3); gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints1.weightx = 0.5; - getContentPane ().add (cancelButton, gridBagConstraints1); - + getContentPane().add(cancelButton, gridBagConstraints1); + }//GEN-END:initComponents private void fileButtonPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileButtonPressed diff --git a/mozilla/l10n/tools/mozxlator/gui/dialog/ReadLocaleDialog.java b/mozilla/l10n/tools/mozxlator/gui/dialog/ReadLocaleDialog.java new file mode 100644 index 00000000000..7d48719b6aa --- /dev/null +++ b/mozilla/l10n/tools/mozxlator/gui/dialog/ReadLocaleDialog.java @@ -0,0 +1,253 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MozillaTranslator (Mozilla Localization Tool) + * + * The Initial Developer of the Original Code is Henrik Lynggaard Hansen + * + * Portions created by Henrik Lynggard Hansen are + * Copyright (C) Henrik Lynggaard Hansen. + * All Rights Reserved. + * + * Contributor(s): + * Henrik Lynggaard Hansen (Initial Code) + * + */ +package org.mozilla.translator.gui.dialog; + +import java.io.*; +import javax.swing.*; + +import org.mozilla.translator.datamodel.*; +import org.mozilla.translator.gui.*; +import org.mozilla.translator.kernel.*; +import javax.swing.*; +/** + * + * @author Henrik + * @version + */ +public class ReadLocaleDialog extends javax.swing.JDialog { + + /** Creates new form ImportOldGlossaryDialog */ + public ReadLocaleDialog() { + super (MainWindow.getDefaultInstance(),"import translarion from mozilla",true); + initComponents (); + getRootPane().setDefaultButton(okButton); + pack (); + + Utils.placeFrameAtCenter(this); + } + + /** 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 FormEditor. + */ + private void initComponents() {//GEN-BEGIN:initComponents + infPanel = new javax.swing.JPanel(); + fileLabel = new javax.swing.JLabel(); + fileField = new javax.swing.JTextField(); + fileButton = new javax.swing.JButton(); + installLabel = new javax.swing.JLabel(); + installCombo = new JComboBox(Glossary.getDefaultInstance().toArray()); + localeLabel = new javax.swing.JLabel(); + localeField = new javax.swing.JTextField(); + okButton = new javax.swing.JButton(); + cancelButton = new javax.swing.JButton(); + getContentPane().setLayout(new java.awt.GridBagLayout()); + java.awt.GridBagConstraints gridBagConstraints1; + setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); + + infPanel.setLayout(new java.awt.GridBagLayout()); + java.awt.GridBagConstraints gridBagConstraints2; + infPanel.setBorder(new javax.swing.border.TitledBorder( + new javax.swing.border.EtchedBorder(), "Information", 4, 2, + new java.awt.Font ("Dialog", 0, 10))); + + fileLabel.setText("Location"); + gridBagConstraints2 = new java.awt.GridBagConstraints(); + gridBagConstraints2.insets = new java.awt.Insets(3, 3, 3, 3); + gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST; + infPanel.add(fileLabel, gridBagConstraints2); + + + fileField.setColumns(20); + fileField.setText("D:\\preo\\fhbndj\\hoigtrod\\glossary.zip"); + gridBagConstraints2 = new java.awt.GridBagConstraints(); + gridBagConstraints2.insets = new java.awt.Insets(3, 0, 3, 0); + gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST; + infPanel.add(fileField, gridBagConstraints2); + + + fileButton.setText("Choose"); + fileButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + fileButtonPressed(evt); + } + } + ); + gridBagConstraints2 = new java.awt.GridBagConstraints(); + gridBagConstraints2.gridwidth = 0; + gridBagConstraints2.insets = new java.awt.Insets(3, 0, 3, 3); + gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST; + infPanel.add(fileButton, gridBagConstraints2); + + + installLabel.setText("Install"); + gridBagConstraints2 = new java.awt.GridBagConstraints(); + gridBagConstraints2.gridx = 0; + gridBagConstraints2.gridy = 1; + gridBagConstraints2.insets = new java.awt.Insets(0, 3, 3, 3); + gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST; + infPanel.add(installLabel, gridBagConstraints2); + + + gridBagConstraints2 = new java.awt.GridBagConstraints(); + gridBagConstraints2.gridx = 1; + gridBagConstraints2.gridy = 1; + gridBagConstraints2.gridwidth = 0; + gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints2.insets = new java.awt.Insets(0, 0, 3, 3); + gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST; + infPanel.add(installCombo, gridBagConstraints2); + + + localeLabel.setText("Locale"); + gridBagConstraints2 = new java.awt.GridBagConstraints(); + infPanel.add(localeLabel, gridBagConstraints2); + + + localeField.setColumns(20); + localeField.setText("jTextField1"); + gridBagConstraints2 = new java.awt.GridBagConstraints(); + infPanel.add(localeField, gridBagConstraints2); + + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridwidth = 0; + gridBagConstraints1.insets = new java.awt.Insets(3, 3, 3, 3); + getContentPane().add(infPanel, gridBagConstraints1); + + + okButton.setText("OK"); + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + okButtonPressed(evt); + } + } + ); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 0; + gridBagConstraints1.gridy = 1; + gridBagConstraints1.insets = new java.awt.Insets(0, 3, 3, 3); + gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST; + gridBagConstraints1.weightx = 0.5; + getContentPane().add(okButton, gridBagConstraints1); + + + cancelButton.setText("Cancel"); + cancelButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cancelButtonPressed(evt); + } + } + ); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 1; + gridBagConstraints1.gridy = 1; + gridBagConstraints1.gridwidth = 0; + gridBagConstraints1.insets = new java.awt.Insets(0, 0, 3, 3); + gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints1.weightx = 0.5; + getContentPane().add(cancelButton, gridBagConstraints1); + + }//GEN-END:initComponents + + private void fileButtonPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileButtonPressed + File defaultFile = new File(fileField.getText()); + JFileChooser dirChooser = new JFileChooser(); + dirChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + dirChooser.setDialogTitle("Select locale directory or jar file to import"); + dirChooser.setSelectedFile(defaultFile); + int result = dirChooser.showDialog(this,"Choose"); + if (result==JFileChooser.APPROVE_OPTION) + { + File dir = dirChooser.getSelectedFile(); + fileField.setText(dir.toString()); + } + }//GEN-LAST:event_fileButtonPressed + + private void okButtonPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonPressed + okay=true; + setVisible(false); + }//GEN-LAST:event_okButtonPressed + + private void cancelButtonPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonPressed + okay=false; + setVisible(false); + }//GEN-LAST:event_cancelButtonPressed + + public boolean visDialog() + { + MozInstall preSelect; + + fileField.setText(Settings.getString("saved.fileName.locale.import","")); + localeField.setText(Settings.getString("saved.localeName","")); + + preSelect = (MozInstall) Glossary.getDefaultInstance().getChildByName(Settings.getString("saved.install","")); + if (preSelect!=null) + { + installCombo.setSelectedItem(preSelect); + } + setVisible(true); + + if (okay) + { + Settings.setString("saved.localeName",localeField.getText()); + Settings.setString("saved.fileName.locale.import",fileField.getText()); + Settings.setString("saved.install",installCombo.getSelectedItem().toString()); + } + + return okay; + } + + public String getFile() + { + return fileField.getText(); + } + + public MozInstall getInstall() + { + return (MozInstall) installCombo.getSelectedItem(); + } + + public String getLocaleName() + { + return localeField.getText(); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel infPanel; + private javax.swing.JLabel fileLabel; + private javax.swing.JTextField fileField; + private javax.swing.JButton fileButton; + private javax.swing.JLabel installLabel; + private javax.swing.JComboBox installCombo; + private javax.swing.JLabel localeLabel; + private javax.swing.JTextField localeField; + private javax.swing.JButton okButton; + private javax.swing.JButton cancelButton; + // End of variables declaration//GEN-END:variables + private boolean okay; +} \ No newline at end of file diff --git a/mozilla/l10n/tools/mozxlator/history.txt b/mozilla/l10n/tools/mozxlator/history.txt index b438d74de05..c77e5275383 100644 --- a/mozilla/l10n/tools/mozxlator/history.txt +++ b/mozilla/l10n/tools/mozxlator/history.txt @@ -2,19 +2,36 @@ Blue sky: + Client/server version with automatiation +known issues: +* doen't handle unsupported file types very well +* escapes : with \: + + Todo: + define command line commands :-) + fix XPI install.js error + remember state on all dialogs (where is it missing?) +Today: +* implement advanced search +* release + +MozillaTranslator 4.2 ++ fixed dtd reading where it cut off the first chars of the keys ++ Advanced Search ++ Small UI changes (spelling errors and the like) ++ Read localizations directly from jar and directory ++ removed debug Log.write() call + + + + MozillaTranslator 4.15 + Now reads installs from jars + Fixed bug with missing comment tags around the "Translated by..." comment in dtd files + Fixed bug where search did work on translated and comment fields + Added about dialog - - MozillaTranslator 4.11 + Fixed bug that made "write package" fail diff --git a/mozilla/l10n/tools/mozxlator/io/CopyWriter.java b/mozilla/l10n/tools/mozxlator/io/CopyWriter.java new file mode 100644 index 00000000000..0f797494147 --- /dev/null +++ b/mozilla/l10n/tools/mozxlator/io/CopyWriter.java @@ -0,0 +1,198 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is MozillaTranslator (Mozilla Localization Tool) + * + * The Initial Developer of the Original Code is Henrik Lynggaard Hansen + * + * Portions created by Henrik Lynggard Hansen are + * Copyright (C) Henrik Lynggaard Hansen. + * All Rights Reserved. + * + * Contributor(s): + * Henrik Lynggaard Hansen (Initial Code) + * + */ + +package org.mozilla.translator.io; + +import java.io.*; +import java.util.jar.*; + + +import java.util.*; +import org.mozilla.translator.datamodel.*; +import org.mozilla.translator.kernel.*; + +/** + * + * @author Henrik Lynggaard + * @version 4.1 + */ +public class CopyWriter extends MozFileWriter +{ + private static String header ="Translated with MozillaTranslator " + Settings.getString("System.Version","(unknown version)") + " "; + + private MozInstall install; + private MozComponent component; + private MozComponent subcomponent; + + public CopyWriter(MozFile f,OutputStream o) + { + super(f,o); + } + + public void writeFile(String localeName) throws IOException + { + + String baseName; + File baseFile; + InputStream is; + boolean theEnd; + int trans; + + Log.write("going to copy : " + fil); + + subcomponent = (MozComponent) fil.getParent(); + Log.write("Got subcomponent " + subcomponent ); + + component = (MozComponent) subcomponent.getParent(); + Log.write("Got component " + component); + + Log.write("parent is " + component.getParent().getName()); + install = (MozInstall) component.getParent(); + Log.write("got Install " + install); + + baseName = install.getPath(); + + baseFile = new File(baseName); + + if (baseFile.isDirectory()) + { + is = getInputFromDirectory(); + } + else + { + is = getInputFromJar(); + } + + theEnd=false; + while (!theEnd) + { + trans = is.read(); + if (trans==-1) + { + theEnd = true; + } + else + { + os.write(trans); + } + } + is.close(); + os.close(); + + } + + private InputStream getInputFromDirectory() + { + FileInputStream result=null; + String fileName; + + fileName = install.getPath(); + fileName = fileName + File.separator + component.getName(); + fileName = fileName + File.separator + "locale"; + + if (subcomponent.getName().equals("MT_default")) + { + fileName= fileName + File.separator + fil.getName(); + } + else + { + fileName= fileName + File.separator + subcomponent.getName(); + fileName= fileName + File.separator + fil.getName(); + } + try + { + result = new FileInputStream(fileName); + } + catch(Exception e) + { + Log.write("Error reading original file for copy: "+ fileName); + } + return result; + } + + private InputStream getInputFromJar() + { + InputStream result=null; + FileInputStream jarFile; + JarInputStream jis; + JarEntry je; + String fileName; + String jarName; + String compareText; + boolean done; + + jarName = install.getPath(); + fileName = component.getName(); + fileName = fileName + "/locale"; + + if (subcomponent.getName().equals("MT_default")) + { + fileName= fileName + "/" + fil.getName(); + } + else + { + fileName= fileName + "/" + subcomponent.getName(); + fileName= fileName + "/" + fil.getName(); + } + try + { + jarFile = new FileInputStream(jarName); + jis = new JarInputStream(jarFile); + + done = false; + + while (!done) + { + je = jis.getNextJarEntry(); + if (je!=null) + { + compareText = je.getName(); + + if (compareText.equalsIgnoreCase(fileName)) + { + result= jis; + done=true; + } + } + else + { + result=null; + done=true; + } + } + } + catch (Exception e) + { + Log.write("Error reading original file for copy: "+ fileName); + } + return result; + + + + + + } + + +} diff --git a/mozilla/l10n/tools/mozxlator/io/DTDReader.java b/mozilla/l10n/tools/mozxlator/io/DTDReader.java index 8b144aeb4c9..c56c4980031 100644 --- a/mozilla/l10n/tools/mozxlator/io/DTDReader.java +++ b/mozilla/l10n/tools/mozxlator/io/DTDReader.java @@ -220,6 +220,7 @@ public class DTDReader extends MozFileReader { { keyBegun= true; entityBuffer= new StringBuffer(); + entityBuffer.append(letter); } } break; diff --git a/mozilla/l10n/tools/mozxlator/io/LocaleAccess.java b/mozilla/l10n/tools/mozxlator/io/LocaleAccess.java new file mode 100644 index 00000000000..6922b515b04 --- /dev/null +++ b/mozilla/l10n/tools/mozxlator/io/LocaleAccess.java @@ -0,0 +1,302 @@ +package org.mozilla.translator.io; + +import java.io.*; +import java.util.*; +import java.util.jar.*; +import org.mozilla.translator.kernel.*; +import org.mozilla.translator.datamodel.*; +import org.mozilla.translator.gui.*; +/** + * + * @author Henrik Lynggaard + * @version 4.20 + */ +public class LocaleAccess implements MozInstallAccess +{ + private MozInstall install; + private String location; + private String localeName; + private MainWindow vindue; + + public LocaleAccess(MozInstall i,String loc,String ln) + { + install=i; + location=loc; + localeName=ln; + vindue = MainWindow.getDefaultInstance(); + } + + public void load() + { + File locFile = new File (location); + + if (locFile.isDirectory()) + { + readFromDirectory(); + } + else + { + if (location.endsWith("jar")); + { + readFromJar(); + } + if (location.endsWith("xpi")); + { + readFromXPI(); + } + } + vindue.setStatus("Ready"); + } + + private void readFromDirectory() + { + int filesDone=0; + File baseFile; + String[] components; + String[] subcomponents; + String[] files; + + File currentComponentFile; + File currentSubcomponentFile; + File currentFileFile; + + MozComponent currentComponent; + MozComponent currentSubcomponent; + MozFile currentFile; + + baseFile = new File(location); + + components = baseFile.list(); + + for (int componentCount=0;componentCount