mt420 release from Henrik.

git-svn-id: svn://10.0.0.236/trunk@79505 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
tao%netscape.com
2000-09-19 03:11:15 +00:00
parent c72110c027
commit 967ad1d080
23 changed files with 1785 additions and 320 deletions

View File

@@ -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;
}
}
}

View File

@@ -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();
}
}
}

View File

@@ -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);

View File

@@ -0,0 +1 @@
javac

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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
}

View File

@@ -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)

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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;
}
}

View File

@@ -220,6 +220,7 @@ public class DTDReader extends MozFileReader {
{
keyBegun= true;
entityBuffer= new StringBuffer();
entityBuffer.append(letter);
}
}
break;

View File

@@ -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<components.length;componentCount++)
{
currentComponent = (MozComponent) install.getChildByName(components[componentCount]);
if (currentComponent!=null)
{
currentComponentFile = new File(location + File.separator + components[componentCount],"locale");
subcomponents = currentComponentFile.list();
for (int subcomponentCount=0;subcomponentCount<subcomponents.length;subcomponentCount++)
{
currentSubcomponentFile = new File (currentComponentFile,subcomponents[subcomponentCount]);
if (currentSubcomponentFile.isDirectory())
{
currentSubcomponent = (MozComponent) currentComponent.getChildByName(subcomponents[subcomponentCount]);
if (currentSubcomponent!=null)
{
files = currentSubcomponentFile.list();
for (int filesCount=0;filesCount<files.length;filesCount++)
{
currentFile = (MozFile) currentSubcomponent.getChildByName(files[filesCount]);
if (currentFile!=null)
{
currentFileFile = new File(currentSubcomponentFile,files[filesCount]);
vindue.setStatus("files done: " + filesDone + ",currently reading: " +currentFile);
readFile( currentFileFile,currentFile);
filesDone++;
}
}
}
}
else
{
currentSubcomponent = (MozComponent) currentComponent.getChildByName("MT_default");
if (currentSubcomponent!=null)
{
currentFile = (MozFile) currentSubcomponent.getChildByName(subcomponents[subcomponentCount]);
if (currentFile!=null)
{
vindue.setStatus("files done: " + filesDone + ",currently reading: " +currentFile);
readFile( currentSubcomponentFile,currentFile);
filesDone++;
}
}
}
}
}
}
}
private void readFromJar()
{
String baseName;
File baseFile;
String[] components;
String[] subcomponents;
String[] files;
String currentComponentString;
String currentSubcomponentString;
String currentFileString;
File currentComponentFile;
File currentSubComponentFile;
File currentFileFile;
MozComponent currentComponent;
MozComponent currentSubComponent;
MozFile currentFile;
Phrase currentPhrase;
Iterator componentIterator;
Iterator subComponentIterator;
Iterator fileIterator;
Iterator phraseIterator;
JarEntry je;
boolean done=false;
StringTokenizer tokens;
String componentToken=null;
String localeToken=null;
String subcomponentToken=null;
String fileToken=null;
int filesDone=0;
try
{
FileInputStream fis = new FileInputStream(location);
JarInputStream jis = new JarInputStream(fis);
BufferedInputStream bis = new BufferedInputStream(jis);
while (!done)
{
je = jis.getNextJarEntry();
if (je!=null)
{
Log.write("je.getName " + je.getName());
tokens = new StringTokenizer(je.getName(),"/",false);
componentToken = tokens.nextToken();
if (tokens.hasMoreTokens())
{
localeToken = tokens.nextToken();
if (tokens.hasMoreTokens())
{
subcomponentToken = tokens.nextToken();
}
if (tokens.hasMoreTokens())
{
fileToken = tokens.nextToken();
}
else
{
fileToken = subcomponentToken;
subcomponentToken="MT_default";
}
}
if (fileToken!=null)
{
currentComponent = (MozComponent) install.getChildByName(componentToken);
if (currentComponent!=null)
{
currentSubComponent = (MozComponent) currentComponent.getChildByName(subcomponentToken);
if (currentSubComponent!=null)
{
currentFile = (MozFile) currentSubComponent.getChildByName(fileToken);
if (currentFile!=null)
{
vindue.setStatus("Files done : " + filesDone + ", currently reading : " +currentFile);
filesDone++;
File tempFile = copyToTemp(je,bis);
readFile(tempFile,currentFile);
tempFile.delete();
componentToken=null;
localeToken=null;
subcomponentToken=null;
fileToken=null;
}
}
}
}
}
else
{
done=true;
}
}
}
catch (Exception e)
{
Log.write("error reading from jar");
Log.write("Exception : " + e);
}
}
private void readFromXPI()
{
// to be done;
}
private void readFile(File r_fil,MozFile m_fil)
{
try
{
MozFileReader reader;
FileInputStream fis;
fis = new FileInputStream(r_fil);
reader = MozIo.getFileReader(m_fil,fis);
if (reader!= null)
{
reader.readFile(localeName);
}
}
catch (Exception e)
{
Log.write("Reak File = " + r_fil);
Log.write("MT file = " + m_fil);
Log.write("Error during file read");
}
}
private File copyToTemp(JarEntry e,BufferedInputStream bis) throws IOException
{
File temp = File.createTempFile("MT_",null);
FileOutputStream fos = new FileOutputStream(temp);
BufferedOutputStream bos = new BufferedOutputStream(fos);
boolean theEnd;
int trans;
theEnd=false;
while (!theEnd)
{
trans = bis.read();
if (trans==-1)
{
theEnd = true;
}
else
{
bos.write(trans);
}
}
bos.close();
return temp;
}
public void save()
{
// does nothing
}
}

View File

@@ -72,7 +72,7 @@ public class MozIo extends Object {
result = new PropertiesWriter(mfil,os);
break;
case MozFile.TYPE_UNSUPPORTED:
result = null;
result = new CopyWriter(mfil,os);
break;
}
return result;

View File

@@ -43,6 +43,8 @@ public class PropertiesWriter extends MozFileWriter
{
super(f,o);
}
public void writeFile(String localeName) throws IOException

View File

@@ -40,7 +40,7 @@ public class DefaultSettings extends Object {
prop = new Properties();
// system settings
prop.setProperty("System.Version","4.15");
prop.setProperty("System.Version","4.20");
prop.setProperty("System.Groupware","false"); // to be used later
prop.setProperty("System.Glossaryfile","glossary.zip");
prop.setProperty("System.Filterfile","Filters.properties");

View File

@@ -0,0 +1,58 @@
/*
* 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.runners;
import java.io.*;
import java.util.*;
import java.util.zip.*;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.io.*;
import org.mozilla.translator.kernel.*;
/**
*
* @author Henrik
* @version
*/
public class ImportLocaleRunner extends Thread {
MozInstall install;
String fileName;
String localeName;
/** Creates new ImportPartialGlossary */
public ImportLocaleRunner(MozInstall i,String fn,String ln)
{
install=i;
fileName=fn;
localeName=ln;
}
public void run()
{
LocaleAccess pa = new LocaleAccess(install,fileName,localeName);
pa.load();
}
}

View File

@@ -328,7 +328,6 @@ public class UpdateInstallRunner extends Thread
if (je!=null)
{
Log.write("je.getName " + je.getName());
tokens = new StringTokenizer(je.getName(),"/",false);
componentToken = tokens.nextToken();
@@ -425,6 +424,8 @@ public class UpdateInstallRunner extends Thread
catch (Exception e)
{
Log.write("Error during file read");
Log.write("Reak File = " + r_fil);
Log.write("MT file = " + m_fil);
}
}

View File

@@ -143,11 +143,17 @@ public class WritePackageRunner extends Thread {
{
fos = new FileOutputStream(dir + File.separator + fil);
writer = MozIo.getFileWriter(fil,fos);
writer.writeFile(localeName);
if (writer!=null)
{
writer.writeFile(localeName);
}
else
{
// should really copy the file
}
}
catch (Exception e)
{
Log.write("Error writing file: " + fil);
Log.write("Exception : "+ e);
}
}