mt415 from henrik

This commit is contained in:
tao%netscape.com 2000-09-19 03:04:18 +00:00
parent 560a653ad5
commit e461a86e6a
84 changed files with 11004 additions and 0 deletions

View File

@ -0,0 +1,34 @@
#Settings for mozillaTranslator
#Thu Sep 07 23:29:04 GMT+02:00 2000
saved.column.1=false
saved.column.0=false
saved.search.rule=2
saved.install=Main
saved.search.case=false
saved.fileName.partial.export=G\:\\testing.zip
saved.search.text=ek
saved.displayName=Danish localization
saved.column.17=false
saved.column.16=false
saved.column.15=false
saved.column.14=false
saved.column.13=false
saved.column.12=false
saved.column.11=false
saved.column.10=true
saved.localeName=da-DK
saved.xpiVersion=1.1
saved.previewURL=about\:blank
saved.Writepackage.File=H\:\\New Folder
saved.column.9=true
saved.search.field=3
saved.column.8=false
saved.column.7=false
saved.column.6=false
saved.column.5=true
saved.author=Henrik Lynggaard
saved.column.4=true
saved.xpiFile=G\:\\testing.xpi
saved.column.3=false
saved.column.2=false
saved.fileName.partial.import=G\:\\testing.zip

View File

@ -0,0 +1,54 @@
/*
* 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.gui.dialog.*;
/**
*
* @author Henrik
* @version 4.15
*/
public class AboutAction extends AbstractAction {
/** Creates new AboutAction */
public AboutAction()
{
super("About MozillaTranslator",null);
}
public void actionPerformed(ActionEvent evt)
{
AboutDialog ad = new AboutDialog();
ad.visDialog();
}
}

View File

@ -0,0 +1,72 @@
/*
* 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 org.mozilla.translator.gui.*;
import org.mozilla.translator.gui.dialog.*;
import org.mozilla.translator.gui.models.*;
/**
* This class represents the chrome view.
*
* @author Henrik Lynggaard Hansen
* @version 4.01
*/
public class ChromeViewAction extends AbstractAction {
/** Creates new InstallManagerAction */
public ChromeViewAction()
{
super("Chrome view",null);
}
/** Displays the chrome view
*
* @param evt the event
*/
public void actionPerformed(ActionEvent evt)
{
List cols;
String lname;
boolean result;
List col = new ArrayList();
ShowWhatDialog swd = new ShowWhatDialog();
result = swd.visDialog();
if (result)
{
cols = swd.getSelectedColumns();
lname= swd.getSelectedLocale();
ChromeView cv = new ChromeView(cols,lname);
}
}
}

View File

@ -0,0 +1,72 @@
/*
* 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 javax.swing.event.*;
import org.mozilla.translator.gui.dialog.*;
import org.mozilla.translator.gui.*;
import org.mozilla.translator.datamodel.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version
*/
public class EditPhraseAction extends AbstractAction {
/** Creates new InstallManagerAction */
public EditPhraseAction()
{
super("Edit Phrase",null);
}
public void actionPerformed(ActionEvent evt)
{
MainWindow mw;
MozFrame mf;
Phrase ph;
String name;
JTable table;
mw = MainWindow.getDefaultInstance();
mf = mw.getInnerFrame();
if (mf!=null)
{
ph = mf.getSelectedPhrase();
if (ph!=null)
{
name = mf.getLocaleName();
table = mf.getTable();
table.editingCanceled(new ChangeEvent(this));
EditPhraseDialog epd = new EditPhraseDialog();
epd.visDialog(ph,name);
}
}
}
}

View File

@ -0,0 +1,69 @@
/*
* 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.gui.dialog.*;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.runners.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version
*/
public class ExportPartialGlossaryAction extends AbstractAction {
/** Creates new InstallManagerAction */
public ExportPartialGlossaryAction()
{
super("Export Partial glossary",null);
}
public void actionPerformed(ActionEvent evt)
{
boolean result;
MozInstall install;
Object[] subcomponents;
String fileName;
ExportPartialGlossaryDialog epg;
ExportPartialGlossaryRunner epr;
epg = new ExportPartialGlossaryDialog();
result = epg.visDialog();
if (result)
{
subcomponents = epg.getSubcomponents();
fileName = epg.getFileName();
install = epg.getInstall();
epr = new ExportPartialGlossaryRunner(install,subcomponents,fileName);
epr.start();
}
}
}

View File

@ -0,0 +1,60 @@
/*
* 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 ImportOldGlossaryAction extends AbstractAction {
/** Creates new InstallManagerAction */
public ImportOldGlossaryAction()
{
super("Import old glossary file",null);
}
public void actionPerformed(ActionEvent evt)
{
ImportGlossaryDialog ig = new ImportGlossaryDialog("Import old glossary",true);
boolean result;
result = ig.visDialog();
if (result)
{
ImportOldGlossaryRunner ior = new ImportOldGlossaryRunner(ig.getInstall(),ig.getFile());
ior.start();
}
}
}

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 ImportPartialGlossaryAction extends AbstractAction {
/** Creates new InstallManagerAction */
public ImportPartialGlossaryAction()
{
super("Import partial glossary",null);
}
public void actionPerformed(ActionEvent evt)
{
ImportGlossaryDialog ig = new ImportGlossaryDialog("Import partial glossary",false);
boolean result;
result = ig.visDialog();
if (result)
{
ImportPartialGlossaryRunner ior = new ImportPartialGlossaryRunner(ig.getInstall(),ig.getFile());
ior.start();
}
}
}

View File

@ -0,0 +1,49 @@
/*
* 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.gui.dialog.*;
import org.mozilla.translator.gui.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version
*/
public class InstallManagerAction extends AbstractAction {
/** Creates new InstallManagerAction */
public InstallManagerAction()
{
super("Manage installs",null);
}
public void actionPerformed(ActionEvent evt)
{
InstallAdminDialog iad = new InstallAdminDialog(MainWindow.getDefaultInstance());
iad.setVisible(true);
}
}

View File

@ -0,0 +1,73 @@
/*
* 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.util.*;
import java.awt.event.*;
import javax.swing.*;
import org.mozilla.translator.gui.dialog.*;
import org.mozilla.translator.gui.*;
import org.mozilla.translator.fetch.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version
*/
public class KeepViewAction extends AbstractAction {
/** Creates new InstallManagerAction */
public KeepViewAction()
{
super("Keep Original",null);
}
public void actionPerformed(ActionEvent evt)
{
List collectedList;
String localeName;
ShowWhatDialog swd;
List cols;
swd = new ShowWhatDialog();
if (swd.visDialog())
{
localeName = swd.getSelectedLocale();
cols = swd.getSelectedColumns();
Fetcher kof = new FetchKeepOriginal();
collectedList = FetchRunner.getFromGlossary(kof);
Collections.sort(collectedList);
ComplexTableWindow ctw = new ComplexTableWindow("Strings with keep original",collectedList,cols,localeName);
}
}
}

View File

@ -0,0 +1,73 @@
/*
* 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.util.*;
import java.awt.event.*;
import javax.swing.*;
import org.mozilla.translator.gui.dialog.*;
import org.mozilla.translator.gui.*;
import org.mozilla.translator.fetch.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version
*/
public class KeybindingCheckerAction extends AbstractAction {
/** Creates new InstallManagerAction */
public KeybindingCheckerAction()
{
super("Check keybindings",null);
}
public void actionPerformed(ActionEvent evt)
{
List collectedList;
String localeName;
ShowWhatDialog swd;
List cols;
swd = new ShowWhatDialog();
if (swd.visDialog())
{
localeName = swd.getSelectedLocale();
cols = swd.getSelectedColumns();
Fetcher kbf = new FetchKeybinding(localeName);
collectedList = FetchRunner.getFromGlossary(kbf);
Collections.sort(collectedList);
ComplexTableWindow ctw = new ComplexTableWindow("String with bad keybinding",collectedList,cols,localeName);
}
}
}

View File

@ -0,0 +1,48 @@
/*
* 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.gui.dialog.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version
*/
public class NoOpAction extends AbstractAction {
/** Creates new InstallManagerAction */
public NoOpAction(String title)
{
super(title,null);
setEnabled(false);
}
public void actionPerformed(ActionEvent evt)
{
// this is a NoOp action, so it does nothing
}
}

View File

@ -0,0 +1,81 @@
/*
* 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.runners.*;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.gui.dialog.*;
import org.mozilla.translator.gui.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version
*/
public class QuitAction extends AbstractAction {
/** Creates new InstallManagerAction */
public QuitAction()
{
super("Quit",null);
}
public void actionPerformed(ActionEvent evt)
{
doExit();
}
public void doExit()
{
int result;
result = JOptionPane.showConfirmDialog(MainWindow.getDefaultInstance(),"Save glossary before quiting ?","Exit MozillaTranslator",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.WARNING_MESSAGE);
if (result==JOptionPane.NO_OPTION)
{
Settings.save();
System.exit(0);
}
if (result==JOptionPane.YES_OPTION)
{
Settings.save();
SaveGlossaryRunner sgr = new SaveGlossaryRunner();
sgr.start();
try
{
sgr.join();
System.exit(0);
}
catch (Exception e)
{
Log.write("Error with saving during exit");
Log.write("Exception : " +e);
}
}
}
}

View File

@ -0,0 +1,156 @@
/*
* 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.util.*;
import java.awt.event.*;
import javax.swing.*;
import org.mozilla.translator.gui.dialog.*;
import org.mozilla.translator.gui.*;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.datamodel.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version 4.01
*/
public class RedundantViewAction extends AbstractAction {
/** Creates new RedundantViewAction */
public RedundantViewAction()
{
super("Reddundant Strings",null);
}
public void actionPerformed(ActionEvent evt)
{
List collectedList;
List redundant;
List all;
Iterator installIterator;
Iterator componentIterator;
Iterator subcomponentIterator;
Iterator fileIterator;
Iterator phraseIterator;
MozInstall spaceInstall = new MozInstall("","");
MozComponent spaceComponent = new MozComponent("",spaceInstall);
MozComponent spaceSubcomponent = new MozComponent("",spaceComponent);
MozFile spaceFile = new MozFile("",spaceSubcomponent);
Phrase spacePhrase = new Phrase("",spaceFile,"","",false);
Glossary glos;
MozInstall currentInstall;
MozComponent currentComponent;
MozComponent currentSubcomponent;
MozFile currentFile;
Phrase currentPhrase,testPhrase;
String localeName;
ShowWhatDialog swd;
List cols;
swd = new ShowWhatDialog();
if (swd.visDialog())
{
localeName = swd.getSelectedLocale();
cols = swd.getSelectedColumns();
collectedList = new ArrayList();
all = new ArrayList();
// select the correct phrases
glos = Glossary.getDefaultInstance();
installIterator = glos.getChildIterator();
// first we all all known phrases to a big list
while (installIterator.hasNext())
{
currentInstall = (MozInstall) installIterator.next();
componentIterator = currentInstall.getChildIterator();
while (componentIterator.hasNext())
{
currentComponent = (MozComponent) componentIterator.next();
subcomponentIterator = currentComponent.getChildIterator();
while (subcomponentIterator.hasNext())
{
currentSubcomponent = (MozComponent) subcomponentIterator.next();
fileIterator = currentSubcomponent.getChildIterator();
while (fileIterator.hasNext())
{
currentFile = (MozFile) fileIterator.next();
all.addAll(currentFile.getAllChildren());
}
}
}
}
// check for redundant original texts
while (all.size()>1)
{
phraseIterator = all.iterator();
redundant = new ArrayList();
testPhrase = (Phrase) phraseIterator.next();
phraseIterator.remove();
redundant.add(testPhrase);
while (phraseIterator.hasNext())
{
currentPhrase = (Phrase) phraseIterator.next();
if (testPhrase.getText().equalsIgnoreCase(currentPhrase.getText()))
{
redundant.add(currentPhrase);
phraseIterator.remove();
}
}
if (redundant.size()>1)
{
collectedList.addAll(redundant);
collectedList.add(spacePhrase);
}
}
// display the phrases
ComplexTableWindow ctw = new ComplexTableWindow("Untranslated strings",collectedList,cols,localeName);
}
}
}

View File

@ -0,0 +1,52 @@
/*
* 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.gui.dialog.*;
import org.mozilla.translator.runners.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version
*/
public class SaveGlossaryAction extends AbstractAction {
/** Creates new InstallManagerAction */
public SaveGlossaryAction()
{
super("Save Glossary",null);
}
public void actionPerformed(ActionEvent evt)
{
SaveGlossaryRunner sgr = new SaveGlossaryRunner();
sgr.start();
}
}

View File

@ -0,0 +1,128 @@
/*
* 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 SearchViewAction extends AbstractAction {
private int rule;
private int column;
private String rul;
private String col;
private boolean cc;
/** Creates new SearchViewAction */
public SearchViewAction()
{
super("Search entries",null);
}
public void actionPerformed(ActionEvent evt)
{
List collectedList;
String lname,text;
MainWindow mw = MainWindow.getDefaultInstance();
SearchDialog sd = new SearchDialog(mw,true);
boolean okay = sd.visDialog();
if (okay)
{
rule= 0;
column =0;
rul = sd.getRule();
col = sd.getColumn();
lname = sd.getLocaleName();
text = sd.getSearchText();
cc = sd.getCase();
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");
Filter search = new Filter(rule,column,text,cc);
ShowWhatDialog swd = new ShowWhatDialog();
swd.disableLocaleField();
if (swd.visDialog())
{
String localeName = swd.getSelectedLocale();
List cols = swd.getSelectedColumns();
Fetcher sf= new FetchSearch(localeName,search);
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,50 @@
/*
* 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.gui.dialog.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version
*/
public class SetupAction extends AbstractAction {
/** Creates new InstallManagerAction */
public SetupAction()
{
super("Setup",null);
}
public void actionPerformed(ActionEvent evt)
{
//SetupDialog sd = new SetupDialog();
//sd.visDialog();
}
}

View File

@ -0,0 +1,73 @@
/*
* 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.util.*;
import java.awt.event.*;
import javax.swing.*;
import org.mozilla.translator.gui.dialog.*;
import org.mozilla.translator.gui.*;
import org.mozilla.translator.fetch.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version
*/
public class UntranslatedViewAction extends AbstractAction {
/** Creates new InstallManagerAction */
public UntranslatedViewAction()
{
super("Untranslated strings",null);
}
public void actionPerformed(ActionEvent evt)
{
List collectedList;
String localeName;
ShowWhatDialog swd;
List cols;
swd = new ShowWhatDialog();
if (swd.visDialog())
{
localeName = swd.getSelectedLocale();
cols = swd.getSelectedColumns();
Fetcher uf = new FetchUntranslated(localeName);
collectedList = FetchRunner.getFromGlossary(uf);
Collections.sort(collectedList);
ComplexTableWindow ctw = new ComplexTableWindow("Untranslated strings",collectedList,cols,localeName);
}
}
}

View File

@ -0,0 +1,66 @@
/*
* 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.gui.dialog.*;
import org.mozilla.translator.gui.*;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.runners.*;
import org.mozilla.translator.kernel.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version 4.0
*/
public class UpdateInstallAction extends AbstractAction {
/** Creates new InstallManagerAction */
public UpdateInstallAction()
{
super("Update Install",null);
}
public void actionPerformed(ActionEvent evt)
{
Object selected;
UpdateInstallRunner ugr;
Object[] installArray;
installArray =Glossary.getDefaultInstance().toArray();
if (installArray.length>0)
{
selected = JOptionPane.showInputDialog(MainWindow.getDefaultInstance(),"Select Install to update","Update installation",JOptionPane.QUESTION_MESSAGE,null,installArray,installArray[0]);
if (selected!=null)
{
ugr = new UpdateInstallRunner((MozInstall) selected);
ugr.start();
}
}
}
}

View File

@ -0,0 +1,66 @@
/*
* 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 WritePackageAction extends AbstractAction {
/** Creates new InstallManagerAction */
public WritePackageAction()
{
super("Write Package",null);
}
public void actionPerformed(ActionEvent evt)
{
WritePackageDialog wpd = new WritePackageDialog();
boolean result;
result = wpd.visDialog();
if (result)
{
String lname = wpd.getLocaleName();
String author = wpd.getAuthor();
String display = wpd.getDisplay();
String preview = wpd.getPreview();
WritePackageRunner wpr = new WritePackageRunner(wpd.getInstall(),wpd.getFile(),lname,author,display,preview);
wpr.start();
}
}
}

View File

@ -0,0 +1,69 @@
/*
* 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 WriteXpiAction extends AbstractAction {
/** Creates new InstallManagerAction */
public WriteXpiAction()
{
super("Write XPI",null);
}
public void actionPerformed(ActionEvent evt)
{
WriteXpiDialog wxd = new WriteXpiDialog();
boolean result;
result = wxd.visDialog();
if (result)
{
String lname = wxd.getLocaleName();
String author = wxd.getAuthor();
String display = wxd.getDisplay();
String preview = wxd.getPreview();
String version = wxd.getVersion();
WriteXpiRunner wpr = new WriteXpiRunner(wxd.getInstall(),wxd.getFile(),lname,author,display,preview,version);
wpr.start();
}
}
}

View File

@ -0,0 +1,186 @@
/*
* 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.datamodel;
import org.mozilla.translator.kernel.*;
/**
*
* @author Henrik
* @version
*/
public class Filter extends Object {
public static final int FIELD_KEY=1;
public static final int FIELD_ORG_TEXT=2;
public static final int FIELD_NOTE=3;
public static final int FIELD_COMMENT=4;
public static final int FIELD_TRANS_TEXT=5;
public static final int RULE_IS=1;
public static final int RULE_IS_NOT=2;
public static final int RULE_CONTAINS=3;
public static final int RULE_CONTAINS_NOT=4;
public static final int RULE_STARTS_WITH=5;
public static final int RULE_ENDS_WITH=6;
private int rule;
private int field;
private int attribute1;
private boolean caseCheck;
private String value;
/** Creates new Filter */
public Filter(int r,int f,String v,boolean cc)
{
rule= r;
field=f;
value=v;
caseCheck=cc;
}
public int getRule()
{
return rule;
}
public int getField()
{
return field;
}
public String getValue()
{
return value;
}
public void setRule(int r)
{
rule=r;
}
public void setField(int f)
{
field=f;
}
public void setValue(String v)
{
value=v;
}
public boolean check(Phrase phrase)
{
return check(phrase,"MT_no_locale");
}
public boolean check(Phrase phrase,String localeName)
{
boolean result;
String compareText;
Translation translation = (Translation) phrase.getChildByName(localeName);
compareText=null;
result = false;
switch (field)
{
case FIELD_KEY:
compareText = phrase.getName();
break;
case FIELD_ORG_TEXT:
compareText = phrase.getText();
break;
case FIELD_NOTE:
compareText = phrase.getNote();
break;
case FIELD_TRANS_TEXT:
if (translation!=null)
{
compareText=translation.getText();
}
break;
case FIELD_COMMENT:
if (translation!=null)
{
compareText=translation.getComment();
}
break;
}
if (compareText!=null)
{
if (!caseCheck)
{
compareText=compareText.toLowerCase();
value=value.toLowerCase();
}
switch (rule)
{
case RULE_IS:
if (compareText.equals(value))
{
result=true;
}
break;
case RULE_IS_NOT:
if (!compareText.equals(value))
{
result=true;
}
break;
case RULE_CONTAINS:
if (compareText.indexOf(value)!=-1)
{
result=true;
}
break;
case RULE_CONTAINS_NOT:
if (compareText.indexOf(value)!=-1)
{
result=true;
}
break;
case RULE_STARTS_WITH:
if (compareText.startsWith(value))
{
result=true;
}
break;
case RULE_ENDS_WITH:
if (compareText.endsWith(value))
{
result=true;
}
break;
}
}
else
{
result=false;
}
return result;
}
}

View File

@ -0,0 +1,96 @@
/*
* 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.datamodel;
import javax.swing.*;
import java.util.*;
/**
*
* @author Henrik
* @version
*/
public class FilterList extends AbstractListModel {
private static FilterList instance;
private List filters;
private int localSize;
public static FilterList getDefaultInstance()
{
if (instance==null)
{
instance = new FilterList();
}
return instance;
}
/** Creates new FilterList */
public FilterList()
{
filters = new ArrayList();
localSize = 0;
}
public Object getElementAt(int pos)
{
return filters.get(pos);
}
public int getSize()
{
return localSize;
}
public void addFilter(Filter value)
{
filters.add(value);
localSize =filters.size();
}
public void removeFilter(Filter value)
{
filters.remove(value);
localSize = filters.size();
}
public boolean check(Phrase phrase)
{
return check(phrase, "MT_no_locale");
}
public boolean check(Phrase phrase,String localeName)
{
Filter f;
Iterator i = filters.iterator();
boolean result=false;
while (i.hasNext() && !result)
{
f = (Filter) i.next();
result = f.check(phrase,localeName);
}
return result;
}
}

View File

@ -0,0 +1,131 @@
/*
* 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.datamodel;
import java.util.*;
import java.io.*;
import javax.swing.*;
import javax.swing.tree.*;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.gui.*;
import org.mozilla.translator.runners.*;
/**
*
* @author Henrik Lynggaard
* @version 5.0
*/
public class Glossary extends MozTreeNode
{
private static Glossary instance;
public static void init()
{
instance = new Glossary();
}
public static Glossary getDefaultInstance()
{
return instance;
}
private Glossary()
{
super("MozillaTranslator Glossary",null);
File glosFile;
glosFile = new File(Settings.getString("System.Glossaryfile","glossary.zip"));
if (glosFile.exists())
{
LoadGlossaryRunner lgr= new LoadGlossaryRunner();
lgr.start();
}
else
{
MainWindow.getDefaultInstance().setStatus("Ready");
}
}
// this needs rewrite!!
public DefaultMutableTreeNode getTreeRoot()
{
DefaultMutableTreeNode root;
DefaultMutableTreeNode installNode;
DefaultMutableTreeNode componentNode;
DefaultMutableTreeNode subcomponentNode;
DefaultMutableTreeNode fileNode;
Iterator installIterator;
Iterator componentIterator;
Iterator subcomponentIterator;
Iterator fileIterator;
MozInstall currentInstall;
MozComponent currentComponent,currentSubcomponent;
MozFile currentFile;
root= new DefaultMutableTreeNode("Root");
installIterator = children.iterator();
while (installIterator.hasNext())
{
currentInstall = (MozInstall) installIterator.next();
installNode = new DefaultMutableTreeNode(currentInstall);
root.add(installNode);
componentIterator = currentInstall.getChildIterator();
while (componentIterator.hasNext())
{
currentComponent = (MozComponent) componentIterator.next();
componentNode = new DefaultMutableTreeNode(currentComponent);
installNode.add(componentNode);
subcomponentIterator = currentComponent.getChildIterator();
while (subcomponentIterator.hasNext())
{
currentSubcomponent = (MozComponent) subcomponentIterator.next();
subcomponentNode = new DefaultMutableTreeNode(currentSubcomponent);
componentNode.add(subcomponentNode);
fileIterator = currentSubcomponent.getChildIterator();
while (fileIterator.hasNext())
{
currentFile = (MozFile) fileIterator.next();
fileNode = new DefaultMutableTreeNode(currentFile);
subcomponentNode.add(fileNode);
}
}
}
}
return root;
}
}

View File

@ -0,0 +1,52 @@
/*
* 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.datamodel;
import java.util.*;
import javax.swing.*;
/**
*
* @author Henrik Lynnggaard
* @version 4.0
*/
public class MozComponent extends MozTreeNode
{
public MozComponent(String n,MozTreeNode p)
{
super(n,p);
}
public String toString()
{
if (name.equals("MT_default"))
return "MT_" + parent.getName();
else
return name;
}
}

View File

@ -0,0 +1,90 @@
/*
* 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.datamodel;
import java.io.*;
import java.util.*;
import javax.swing.*;
import org.mozilla.translator.io.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version 4.0
*/
public class MozFile extends MozTreeNode
{
public static final int TYPE_DTD=1;
public static final int TYPE_PROP=2;
public static final int TYPE_RDF=3;
public static final int TYPE_UNSUPPORTED=4;
private int type;
/** Creates new MozFile */
public MozFile(String n,MozTreeNode p)
{
super(n,p);
if (n.endsWith(".dtd"))
{
type=TYPE_DTD;
}
else if (n.endsWith(".properties"))
{
type=TYPE_PROP;
}
else
{
type=TYPE_UNSUPPORTED;
}
}
public int getType()
{
return type;
}
public void setName(String fileName)
{
this.name=fileName;
if (fileName.endsWith(".dtd"))
{
type=TYPE_DTD;
}
else if (fileName.endsWith(".properties"))
{
type=TYPE_PROP;
}
else
{
type=TYPE_UNSUPPORTED;
}
}
}

View File

@ -0,0 +1,55 @@
/*
* 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.datamodel;
import java.util.*;
import javax.swing.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version
*/
public class MozInstall extends MozTreeNode
{
private String path;
/** Creates new MozInstall */
public MozInstall(String n,String p)
{
super(n,null);
path=p;
}
public String getPath()
{
return path;
}
public void setPath(String path)
{
this.path=path;
}
}

View File

@ -0,0 +1,151 @@
/*
* 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.datamodel;
import java.util.*;
import javax.swing.*;
/**
*
* @author Henrik Lynggaard
* @version 4.1
*/
public class MozTreeNode extends AbstractListModel implements Comparable {
protected List children;
protected String name;
protected MozTreeNode parent;
protected boolean marked;
/** Creates new MozTreeNode */
public MozTreeNode(String n,MozTreeNode p)
{
name= n;
parent = p;
children = new ArrayList();
marked=false;
}
public void setName(String name)
{
this.name=name;
}
public String getName()
{
return this.name;
}
public MozTreeNode getParent()
{
return parent;
}
public boolean isMarked()
{
return marked;
}
public void setMarked(boolean m)
{
marked=m;
}
public void addChild(MozTreeNode child)
{
children.add(child);
}
public void removeChild(MozTreeNode child)
{
children.remove(child);
}
public MozTreeNode getChildByName(String name)
{
Iterator childIterator;
MozTreeNode child,result;
boolean done;
childIterator = children.iterator();
done=false;
result=null;
while (!done && childIterator.hasNext())
{
child = (MozTreeNode) childIterator.next();
if (name.equals(child.getName()))
{
done=true;
result=child;
}
}
return result;
}
public Iterator getChildIterator()
{
return children.iterator();
}
public List getAllChildren()
{
return children;
}
public String toString()
{
return name;
}
// Methods for the AbstractListModel
public int getSize()
{
return children.size();
}
public Object getElementAt(int index)
{
return children.get(index);
}
public void fireContentsChanged()
{
fireContentsChanged(this,0,children.size());
}
public Object[] toArray()
{
return children.toArray();
}
public int compareTo(final java.lang.Object pl)
{
MozTreeNode other = (MozTreeNode) pl;
return name.compareTo(other.name);
}
}

View File

@ -0,0 +1,107 @@
/*
* 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.datamodel;
import java.util.*;
import javax.swing.*;
/**
*
* @author Henrik Lynggaard
* @version 4.0
*/
public class Phrase extends MozTreeNode {
private String text;
private String note;
private boolean keepOriginal;
private Phrase accessConnection;
private Phrase commandConnection;
/** Creates new Phrase */
public Phrase(String n,MozTreeNode p,String original,String note,boolean keepOriginal)
{
super(n,p);
this.text=original;
this.note=note;
this.keepOriginal=keepOriginal;
this.accessConnection=null;
this.commandConnection=null;
}
public String getText()
{
return text;
}
public String getNote()
{
return note;
}
public boolean getKeepOriginal()
{
return keepOriginal;
}
public Phrase getAccessConnection()
{
return accessConnection;
}
public Phrase getCommandConnection()
{
return commandConnection;
}
public void setText(String text)
{
this.text=text;
}
public void setNote(String note)
{
this.note=note;
}
public void setKeepOriginal(boolean flag)
{
this.keepOriginal=flag;
}
public void setAccessConnection(Phrase phrase)
{
this.accessConnection=phrase;
}
public void setCommandConnection(Phrase phrase)
{
this.commandConnection=phrase;
}
}

View File

@ -0,0 +1,97 @@
/*
* 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.datamodel;
import org.mozilla.translator.kernel.*;
/**
*
* @author Henrik
* @version
*/
public class Translation extends MozTreeNode{
public static final int QA_NOTSEEN=0;
public static final int QA_SKIPPED=1;
public static final int QA_ERROR=2;
public static final int QA_CHANGE=3;
public static final int QA_ACCEPTED=4;
public static final int QA_PERFECT=5;
public static final int QA_OTHER=6;
private String text;
private int status;
private String comment;
/** Creates new Translation */
public Translation(String n,MozTreeNode p,String t)
{
super (n,p);
this.text=t;
this.status=QA_NOTSEEN;
this.comment="";
}
public Translation(String n,MozTreeNode p,String t,int s,String c)
{
super(n,p);
this.text=t;
this.status=s;
this.comment=c;
}
public String getText()
{
return text;
}
public int getStatus()
{
return status;
}
public String getComment()
{
return comment;
}
public void setText(String t)
{
this.text=t;
}
public void setStatus(int s)
{
this.status=s;
}
public void setComment(String comment)
{
this.comment=comment;
}
}

View File

@ -0,0 +1,31 @@
/*
* 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 FetchKeepOriginal implements Fetcher
{
/** Creates new FetchUntranslated */
public FetchKeepOriginal()
{
// do nothing
}
public boolean check(Phrase ph)
{
return ph.getKeepOriginal();
}
}

View File

@ -0,0 +1,96 @@
/*
* FetchKaybinding.java
*
* Created on 19. august 2000, 21:07
*/
package org.mozilla.translator.fetch;
import org.mozilla.translator.datamodel.*;
/**
*
* @author Henrik Lynggaard
* @version
*/
public class FetchKeybinding implements Fetcher {
private String localeName;
/** Creates new FetchKaybinding */
public FetchKeybinding(String ln)
{
localeName =ln;
}
public boolean check(Phrase ph)
{
boolean result;
Phrase commandPhrase,accessPhrase;
Translation currentTranslation,commandTranslation,accessTranslation;
String text,key;
result = false;
// find the correct text
currentTranslation = (Translation) ph.getChildByName(localeName);
if (currentTranslation==null)
{
text = ph.getText();
}
else
{
text = currentTranslation.getText();
}
// check for command
commandPhrase = ph.getCommandConnection();
if (commandPhrase!=null)
{
commandTranslation = (Translation) commandPhrase.getChildByName(localeName);
if (commandTranslation ==null)
{
key = commandPhrase.getText();
}
else
{
key = commandTranslation.getText();
}
text = text.toLowerCase();
key = key.toLowerCase();
if (text.indexOf(key)==-1)
{
result=true;
}
}
// check for access
accessPhrase = ph.getAccessConnection();
if (accessPhrase!=null)
{
accessTranslation = (Translation) accessPhrase.getChildByName(localeName);
if (accessTranslation ==null)
{
key = accessPhrase.getText();
}
else
{
key = accessTranslation.getText();
}
text = text.toLowerCase();
key = key.toLowerCase();
if (text.indexOf(key)==-1)
{
result=true;
}
}
return result;
}
}

View File

@ -0,0 +1,95 @@
/*
* FetchRunner.java
*
* Created on 19. august 2000, 13:01
*/
package org.mozilla.translator.fetch;
import java.util.*;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.gui.*;
/**
*
* @author Henrik Lynggaard
* @version
*/
public class FetchRunner
{
public static List getFromGlossary(Fetcher fetch)
{
Glossary glos;
Iterator installIterator;
MozInstall currentInstall;
List allList,installList;
glos = Glossary.getDefaultInstance();
allList = new ArrayList();
installIterator = glos.getChildIterator();
while (installIterator.hasNext())
{
currentInstall = (MozInstall) installIterator.next();
installList = getFromInstall(currentInstall,fetch);
allList.addAll(installList);
}
return allList;
}
public static List getFromInstall(MozInstall install,Fetcher fetch)
{
Iterator componentIterator;
Iterator subcomponentIterator;
Iterator fileIterator;
Iterator phraseIterator;
MozComponent currentComponent;
MozComponent currentSubcomponent;
MozFile currentFile;
Phrase currentPhrase;
MainWindow vindue = MainWindow.getDefaultInstance();
int filesDone=0;
List result = new ArrayList();
componentIterator = install.getChildIterator();
while (componentIterator.hasNext())
{
currentComponent = (MozComponent) componentIterator.next();
subcomponentIterator = currentComponent.getChildIterator();
while (subcomponentIterator.hasNext())
{
currentSubcomponent = (MozComponent) subcomponentIterator.next();
fileIterator = currentSubcomponent.getChildIterator();
while (fileIterator.hasNext())
{
currentFile = (MozFile) fileIterator.next();
vindue.setStatus("Files done: " + filesDone + ", currently handling : " + currentFile);
filesDone++;
phraseIterator = currentFile.getChildIterator();
while (phraseIterator.hasNext())
{
currentPhrase = (Phrase) phraseIterator.next();
if (fetch.check(currentPhrase))
{
result.add(currentPhrase);
}
}
}
}
}
vindue.setStatus("Ready");
return result;
}
}

View File

@ -0,0 +1,34 @@
/*
* 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 FetchSearch implements Fetcher
{
private String localeName;
private Filter filt;
/** Creates new FetchUntranslated */
public FetchSearch(String ln,Filter f)
{
localeName = ln;
filt=f;
}
public boolean check(Phrase ph)
{
return filt.check(ph,localeName);
}
}

View File

@ -0,0 +1,45 @@
/*
* 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 FetchUntranslated implements Fetcher
{
private String localeName;
/** Creates new FetchUntranslated */
public FetchUntranslated(String ln)
{
localeName = ln;
}
public boolean check(Phrase ph)
{
boolean result;
Translation currentTranslation;
currentTranslation = (Translation) ph.getChildByName(localeName);
if (currentTranslation==null)
{
result=true;
}
else
{
result=false;
}
return result;
}
}

View File

@ -0,0 +1,19 @@
/*
* Fetcher.java
*
* Created on 19. august 2000, 12:59
*/
package org.mozilla.translator.fetch;
import org.mozilla.translator.datamodel.*;
/**
*
* @author Henrik Lynggaard
* @version
*/
public interface Fetcher
{
public boolean check(Phrase ph);
}

View File

@ -0,0 +1,45 @@
install.count = number of installs
<i_num>.name = name of install
<i_num>.path = path of install
<i_num>.locale = default locale for install
<i_num>.count = number of components in install
<i_num>.<c_num>.name = name of the component
<i_num>.<c_num>.count = number of subcomponents
<i_num>.<c_num>.<s_num>.name= name of the sub component
<i_num>.<c_num>.<s_num>.count = number of files
<i_num>.<c_num>.<s_num>.<f_num>.name = name of file
<i_num>.<c_num>.<s_num>.<f_num>.count = number of phrases
<i_num>.<c_num>.<s_num>.<f_num>.<p_num>.key = the key
<i_num>.<c_num>.<s_num>.<f_num>.<p_num>.note = the any localization comment.
<i_num>.<c_num>.<s_num>.<f_num>.<p_num>.text = the original text
<i_num>.<c_num>.<s_num>.<f_num>.<p_num>.count = the number of translations
<i_num>.<c_num>.<s_num>.<f_num>.<p_num>.keep = keep original flag
<i_num>.<c_num>.<s_num>.<f_num>.<p_num>.<t_num>.name = the locale name
<i_num>.<c_num>.<s_num>.<f_num>.<p_num>.<t_num>.comment = the QA comment
<i_num>.<c_num>.<s_num>.<f_num>.<p_num>.<t_num>.status = any QA status
<i_num>.<c_num>.<s_num>.<f_num>.<p_num>.<t_num>.text = the translated text
Format for partial glossary files:
subcomponent.count = number of components
<s_num>.name = name of the subcomponent
<s_num>.parent = name of parent component
<s_num>.count = number of files
<s_num>.<f_num>.name = name of file
<s_num>.<f_num>.count = number of phrases
<s_num>.<f_num>.<p_num>.key = the key
<s_num>.<f_num>.<p_num>.count = the number of translations
<s_num>.<f_num>.<p_num>.<t_num>.name = the locale name
<s_num>.<f_num>.<p_num>.<t_num>.comment = the QA comment
<s_num>.<f_num>.<p_num>.<t_num>.status = any QA status
<s_num>.<f_num>.<p_num>.<t_num>.text = the translated text

View File

@ -0,0 +1,160 @@
/*
* 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;
import java.awt.BorderLayout;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import javax.swing.tree.*;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.gui.models.*;
/**
*
* @author Henrik
* @version 4.0
*/
public class ChromeView extends JInternalFrame implements TreeSelectionListener,MozFrame
{
private List cols;
private String localeName;
private ComplexTableModel model;
private JTree tree;
private JTable table;
private DefaultMutableTreeNode root;
private JScrollPane treeScroll;
private JScrollPane tableScroll;
private JSplitPane split;
/** Creates new ChromeView */
public ChromeView(List wCols,String l)
{
super("Chrome view for " + l);
MozInstall notLoadedInstall;
MozComponent notLoadedComponent;
MozComponent notLoadedSubcomponent;
MozFile notLoadedFile;
Phrase notLoadedPhrase;
List notLoadedList;
cols = wCols;
localeName=l;
setClosable(true);
setMaximizable(true);
setIconifiable(true);
setResizable(true);
notLoadedInstall = new MozInstall("not loaded","not loaded");
notLoadedComponent = new MozComponent("not loaded",notLoadedInstall);
notLoadedSubcomponent = new MozComponent("not loaded",notLoadedComponent);
notLoadedFile = new MozFile("not loaded",notLoadedSubcomponent);
notLoadedPhrase = new Phrase("not loaded",notLoadedFile,"not loaded","not loaded",false);
notLoadedList = new ArrayList();
notLoadedList.add(notLoadedPhrase);
root = Glossary.getDefaultInstance().getTreeRoot();
tree = new JTree(root);
tree.addTreeSelectionListener(this);
tree.setRootVisible(false);
treeScroll = new JScrollPane(tree);
model = new ComplexTableModel(notLoadedList,cols,localeName);
table = new JTable(model);
tableScroll = new JScrollPane(table);
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,treeScroll,tableScroll);
getContentPane().add(split,BorderLayout.CENTER);
pack();
MainWindow.getDefaultInstance().addWindow(this);
split.setOneTouchExpandable(true);
try
{
setMaximum(true);
}
catch (Exception e) { /* silently ignore */ }
split.setDividerLocation(0.30);
setVisible(true);
}
public void valueChanged(TreeSelectionEvent evt)
{
TreePath tp;
int pathCount;
List relevant;
DefaultMutableTreeNode lastNode;
MozFile theFile;
List ps;
tp = evt.getNewLeadSelectionPath();
pathCount= tp.getPathCount();
if (pathCount==5)
{
lastNode = (DefaultMutableTreeNode) tp.getLastPathComponent();
theFile = (MozFile) lastNode.getUserObject();
ps = theFile.getAllChildren();
model = new ComplexTableModel(ps,cols,localeName);
table.setModel(model);
}
}
public Phrase getSelectedPhrase()
{
int rowIndex;
rowIndex = table.getSelectedRow();
return model.getRow(rowIndex);
}
public String getLocaleName()
{
return localeName;
}
public JTable getTable()
{
return table;
}
}

View File

@ -0,0 +1,78 @@
/*
* 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;
import javax.swing.*;
import java.util.*;
import org.mozilla.translator.gui.models.*;
import org.mozilla.translator.datamodel.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version 4.0
*/
public class ComplexTableWindow extends JInternalFrame implements MozFrame{
private JTable table;
private JScrollPane scroll;
private ComplexTableModel model;
/** Creates new ComplexTableWindow */
public ComplexTableWindow(String title,List toModel,List cols,String localeName)
{
super(title);
setClosable(true);
setMaximizable(true);
setIconifiable(true);
setResizable(true);
model = new ComplexTableModel(toModel,cols,localeName);
table = new JTable(model);
scroll = new JScrollPane(table);
getContentPane().add(scroll,"Center");
pack();
MainWindow.getDefaultInstance().addWindow(this);
setVisible(true);
}
public Phrase getSelectedPhrase()
{
int rowIndex;
rowIndex = table.getSelectedRow();
return model.getRow(rowIndex);
}
public String getLocaleName()
{
return model.getLocaleName();
}
public JTable getTable()
{
return table;
}
}

View File

@ -0,0 +1,170 @@
/*
* 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;
import java.awt.*;
import javax.swing.*;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.actions.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version 4.0
*/
public class MainWindow extends JFrame {
private static MainWindow instance;
private JLabel statusLine;
private JDesktopPane desktop;
private JMenuBar menuBar;
private JMenu fileMenu;
private JMenu glossaryMenu;
private JMenu commandMenu;
private JMenu viewMenu;
private JMenu helpMenu;
public static void init()
{
instance = new MainWindow();
}
public static MainWindow getDefaultInstance()
{
return instance;
}
/** Creates new MainWindow */
private MainWindow()
{
super("MozillaTranslator, Version " + Settings.getString("System.Version","X.xx"));
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
desktop = new JDesktopPane();
statusLine = new JLabel("Status: Loading...");
menuBar = new JMenuBar();
// the file menu
fileMenu = new JMenu("File");
addMenuItem(fileMenu,new InstallManagerAction(),"");
fileMenu.addSeparator();
// addMenuItem(fileMenu,new SetupAction(),"");
//fileMenu.addSeparator();
addMenuItem(fileMenu,new QuitAction(),"");
menuBar.add(fileMenu);
// the glossary menu
glossaryMenu = new JMenu("Glossary");
addMenuItem(glossaryMenu , new UpdateInstallAction(), "alt shift U");
addMenuItem(glossaryMenu , new SaveGlossaryAction(), "alt shift S");
glossaryMenu.addSeparator();
addMenuItem(glossaryMenu , new WritePackageAction(), "alt shift I");
addMenuItem(glossaryMenu , new WriteXpiAction(), "alt shift X");
glossaryMenu.addSeparator();
addMenuItem(glossaryMenu , new ImportPartialGlossaryAction(), "control shift I");
addMenuItem(glossaryMenu , new ExportPartialGlossaryAction(), "control shift E");
// glossaryMenu.addSeparator();
// addMenuItem(glossaryMenu , new NoOpAction("ImportMozExpAction()"), "");
// addMenuItem(glossaryMenu , new NoOpAction("ExportMozExpAction()"), "");
glossaryMenu.addSeparator();
addMenuItem(glossaryMenu , new ImportOldGlossaryAction(),"");
menuBar.add(glossaryMenu);
// the Command Menu
commandMenu = new JMenu("Functions");
addMenuItem(commandMenu , new NoOpAction("SummaryReportAction()"), "");
addMenuItem(commandMenu , new KeybindingCheckerAction(), "");
commandMenu.addSeparator();
addMenuItem(commandMenu , new NoOpAction("HTMLExportAction()"), "");
commandMenu.addSeparator();
addMenuItem(commandMenu , new EditPhraseAction(), "alt E");
menuBar.add(commandMenu);
//The view menu
viewMenu = new JMenu("Views");
addMenuItem(viewMenu , new ChromeViewAction(), "alt C");
addMenuItem(viewMenu , new UntranslatedViewAction() , "alt U");
addMenuItem(viewMenu , new RedundantViewAction(), "alt R");
addMenuItem(viewMenu , new KeepViewAction(), "alt K");
addMenuItem(viewMenu , new SearchViewAction(), "alt S");
menuBar.add(viewMenu);
helpMenu = new JMenu("Help");
addMenuItem(helpMenu, new AboutAction(),"");
menuBar.add(helpMenu);
// build the window
setJMenuBar(menuBar);
getContentPane().add(desktop, BorderLayout.CENTER);
getContentPane().add(statusLine, BorderLayout.SOUTH);
setSize(800,600);
Utils.placeFrameAtCenter(this);
}
public void setStatus(String text)
{
statusLine.setText(text);
}
public void addWindow(JInternalFrame win)
{
desktop.add(win);
}
private void addMenuItem(JMenu adMenu,Action action,String key)
{
JMenuItem item;
item = adMenu.add(action);
if (!key.equals(""))
{
item.setAccelerator(KeyStroke.getKeyStroke(key));
}
}
public MozFrame getInnerFrame()
{
return (MozFrame) desktop.getSelectedFrame();
}
}

View File

@ -0,0 +1,42 @@
/*
* 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;
import javax.swing.*;
import org.mozilla.translator.datamodel.*;
/**
*
* @author Henrik
* @version
*/
public interface MozFrame {
public Phrase getSelectedPhrase();
public String getLocaleName();
public JTable getTable();
}

View File

@ -0,0 +1,67 @@
/*
* 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;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version 4.0
*/
public class TextWindow extends JInternalFrame {
private JTextArea ta;
private JScrollPane sp;
/** Creates new TextWindow */
public TextWindow(String title)
{
super(title);
setClosable(true);
setMaximizable(true);
setIconifiable(true);
setResizable(true);
ta = new JTextArea(10,40);
ta.setEditable(false);
sp = new JScrollPane(ta);
getContentPane().add(sp,"Center");
pack();
MainWindow.getDefaultInstance().addWindow(this);
}
public void append(String text)
{
ta.append(text);
}
}

View File

@ -0,0 +1,133 @@
/*
* AboutDialog.java
*
* Created on 7. september 2000, 22:55
*/
package org.mozilla.translator.gui.dialog;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.gui.*;
/**
*
* @author Henrik Lynggaard
* @version 4.15
*/
public class AboutDialog extends javax.swing.JDialog {
/** Creates new form AboutDialog */
public AboutDialog() {
super(MainWindow.getDefaultInstance(),"MozillaTRanslator version " + Settings.getString("System.Version","unknown"),true);
initComponents ();
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
okPanel = new javax.swing.JPanel();
okButton = new javax.swing.JButton();
tabPanel = new javax.swing.JTabbedPane();
generelPanel = new javax.swing.JPanel();
generelArea = new javax.swing.JTextArea();
licencePanel = new javax.swing.JPanel();
licenceArea = new javax.swing.JTextArea();
postcardPanel = new javax.swing.JPanel();
addressArea = new javax.swing.JTextArea();
String dialogTitle = "MozillaTranslator version 4.15";
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
}
);
okButton.setToolTipText("Close this dialog");
okButton.setText("Ok");
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonPressed(evt);
}
}
);
okPanel.add(okButton);
getContentPane().add(okPanel, java.awt.BorderLayout.SOUTH);
tabPanel.setFont(new java.awt.Font ("Dialog", 0, 12));
generelPanel.setLayout(new java.awt.BorderLayout());
generelArea.setDisabledTextColor(java.awt.Color.black);
generelArea.setEditable(false);
generelArea.setColumns(20);
generelArea.setFont(new java.awt.Font ("Monospaced", 0, 12));
generelArea.setText(" MozillaTranslator\n\na localization tool for Mozilla\nand other XUL based programs.\n\nOriginal code by:\nHenrik Lynggaard\nDenmark\n");
generelArea.setBackground(java.awt.Color.lightGray);
generelPanel.add(generelArea, java.awt.BorderLayout.CENTER);
tabPanel.addTab("Generel", null, generelPanel, "generel about");
licencePanel.setLayout(new java.awt.BorderLayout());
licenceArea.setEditable(false);
licenceArea.setText("MozillaTranslator is released under MPL \nand PostCardWare\n\nMPL (Mozilla Public Licence 1.1)\nhttp://www.mozilla.org\n\nPostCardWare:\nIf you like this program,\nyou are encuraged to send a postcard\n(snail mail) to the author.\n");
licenceArea.setBackground(java.awt.Color.lightGray);
licencePanel.add(licenceArea, java.awt.BorderLayout.CENTER);
tabPanel.addTab("Licence", null, licencePanel, "Licence Information");
postcardPanel.setLayout(new java.awt.BorderLayout());
addressArea.setEditable(false);
addressArea.setText("Postcards should be sent to:\n\nHenrik Lynggaard\nBakkesvinget 22\nTulstrup\n3400 Hilleroed\nDenmark\n");
addressArea.setBackground(java.awt.Color.lightGray);
postcardPanel.add(addressArea, java.awt.BorderLayout.CENTER);
tabPanel.addTab("Address", null, postcardPanel, "Postcard address");
getContentPane().add(tabPanel, java.awt.BorderLayout.CENTER);
}//GEN-END:initComponents
private void okButtonPressed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonPressed
setVisible (false);
dispose ();
}//GEN-LAST:event_okButtonPressed
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
setVisible (false);
dispose ();
}//GEN-LAST:event_closeDialog
public void visDialog()
{
setVisible(true);
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel okPanel;
private javax.swing.JButton okButton;
private javax.swing.JTabbedPane tabPanel;
private javax.swing.JPanel generelPanel;
private javax.swing.JTextArea generelArea;
private javax.swing.JPanel licencePanel;
private javax.swing.JTextArea licenceArea;
private javax.swing.JPanel postcardPanel;
private javax.swing.JTextArea addressArea;
// End of variables declaration//GEN-END:variables
}

View File

@ -0,0 +1,259 @@
/*
* AdvancedSearchDialog.java
*
* Created on 6. september 2000, 21:11
*/
package org.mozilla.translator.gui.dialog;
/**
*
* @author Henrik Lynggaard
* @version
*/
public class AdvancedSearchDialog extends javax.swing.JDialog {
/** Creates new form AdvancedSearchDialog */
public AdvancedSearchDialog(java.awt.Frame parent,boolean modal) {
super (parent, modal);
initComponents ();
pack ();
}
/** 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
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);
}
}
);
jLabel1.setText("Field");
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 1;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
getContentPane().add(jLabel1, gridBagConstraints1);
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
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
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 ();
}
// 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
}

View File

@ -0,0 +1,243 @@
/*
* 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.kernel.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version
*/
public class EditInstallDialog extends javax.swing.JDialog {
/** Creates new form EditInstallDialog */
public EditInstallDialog(java.awt.Frame parent,MozInstall mzi) {
super (parent,"Edit Installation",true);
install=mzi;
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
infoPanel = new javax.swing.JPanel();
nameLabel = new javax.swing.JLabel();
nameField = new javax.swing.JTextField();
pathLabel = new javax.swing.JLabel();
pathField = new javax.swing.JTextField();
pathButton = new javax.swing.JButton();
buttonPanel = new javax.swing.JPanel();
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);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeWindow(evt);
}
}
);
infoPanel.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints2;
infoPanel.setBorder(new javax.swing.border.TitledBorder(
new javax.swing.border.EtchedBorder(), "Install Information", 4, 2,
new java.awt.Font ("Dialog", 0, 10)));
nameLabel.setText("Name");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infoPanel.add(nameLabel, gridBagConstraints2);
nameField.setColumns(30);
nameField.setText("Mozilla M16");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 0, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infoPanel.add(nameField, gridBagConstraints2);
pathLabel.setText("Path");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 3, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infoPanel.add(pathLabel, gridBagConstraints2);
pathField.setColumns(30);
pathField.setText("C:\\program files\\mozilla\\chrome");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 3, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infoPanel.add(pathField, gridBagConstraints2);
pathButton.setText("Choose");
pathButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pathButtonPressed(evt);
}
}
);
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 2;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 3, 3);
infoPanel.add(pathButton, gridBagConstraints2);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.insets = new java.awt.Insets(3, 3, 3, 3);
getContentPane().add(infoPanel, gridBagConstraints1);
buttonPanel.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints3;
okButton.setToolTipText("Leaves and saves the information");
okButton.setText("OK");
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonPressed(evt);
}
}
);
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 0;
gridBagConstraints3.insets = new java.awt.Insets(0, 3, 3, 2);
gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHEAST;
buttonPanel.add(okButton, gridBagConstraints3);
cancelButton.setToolTipText("Leaveswithout saving the information");
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonPressed(evt);
}
}
);
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 1;
gridBagConstraints3.gridy = 0;
gridBagConstraints3.gridwidth = 0;
gridBagConstraints3.insets = new java.awt.Insets(0, 2, 3, 3);
gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHWEST;
buttonPanel.add(cancelButton, gridBagConstraints3);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.insets = new java.awt.Insets(0, 3, 3, 3);
getContentPane().add(buttonPanel, gridBagConstraints1);
}//GEN-END:initComponents
private void pathButtonPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pathButtonPressed
File defaultFile = new File(pathField.getText());
JFileChooser dirChooser = new JFileChooser();
dirChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
dirChooser.setDialogTitle("Select directory for the install");
dirChooser.setSelectedFile(defaultFile);
int result = dirChooser.showDialog(this,"Choose");
if (result==JFileChooser.APPROVE_OPTION)
{
File dir = dirChooser.getSelectedFile();
pathField.setText(dir.toString());
}
}//GEN-LAST:event_pathButtonPressed
private void closeWindow (java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeWindow
okay=false;
setVisible(false);
}//GEN-LAST:event_closeWindow
private void cancelButtonPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonPressed
okay=false;
setVisible(false);
}//GEN-LAST:event_cancelButtonPressed
private void okButtonPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonPressed
okay=true;
setVisible(false);
}//GEN-LAST:event_okButtonPressed
public boolean visDialog()
{
nameField.setText(install.getName());
pathField.setText(install.getPath());
setVisible(true);
if (okay)
{
install.setPath(pathField.getText());
install.setName(nameField.getText());
}
dispose();
return okay;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel infoPanel;
private javax.swing.JLabel nameLabel;
private javax.swing.JTextField nameField;
private javax.swing.JLabel pathLabel;
private javax.swing.JTextField pathField;
private javax.swing.JButton pathButton;
private javax.swing.JPanel buttonPanel;
private javax.swing.JButton okButton;
private javax.swing.JButton cancelButton;
// End of variables declaration//GEN-END:variables
private boolean okay;
private MozInstall install;
}

View File

@ -0,0 +1,757 @@
/*
* 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 javax.swing.*;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.gui.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version
*/
public class EditPhraseDialog extends javax.swing.JDialog {
/** Creates new form PhrasePropertyWindow */
public EditPhraseDialog()
{
super (MainWindow.getDefaultInstance(),"Edit Phrase",true);
initComponents ();
getRootPane().setDefaultButton(okayButton);
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
basicPanel = new javax.swing.JPanel();
InstallLabel = new javax.swing.JLabel();
installField = new javax.swing.JTextField();
componentLabel = new javax.swing.JLabel();
componentField = new javax.swing.JTextField();
fileLabel = new javax.swing.JLabel();
fileField = new javax.swing.JTextField();
keyLabel = new javax.swing.JLabel();
keyField = new javax.swing.JTextField();
subcomponentLabel = new javax.swing.JLabel();
subcomponentField = new javax.swing.JTextField();
accessConnectLabel = new javax.swing.JLabel();
accessConnectField = new javax.swing.JTextField();
commandConnectLabel = new javax.swing.JLabel();
commandConnectField = new javax.swing.JTextField();
orignalPanel = new javax.swing.JPanel();
textLabel = new javax.swing.JLabel();
keepLabel = new javax.swing.JLabel();
keepCheck = new javax.swing.JCheckBox();
noteLabel = new javax.swing.JLabel();
originalScroll = new javax.swing.JScrollPane();
originalArea = new javax.swing.JTextArea();
noteScroll = new javax.swing.JScrollPane();
noteArea = new javax.swing.JTextArea();
accessOriginalLabel = new javax.swing.JLabel();
acessOriginalField = new javax.swing.JTextField();
commandOriginalLabel = new javax.swing.JLabel();
commandOriginalField = new javax.swing.JTextField();
translatedPanel = new javax.swing.JPanel();
translatedLabel = new javax.swing.JLabel();
accessTranslatedLabel = new javax.swing.JLabel();
accessTranslatedField = new javax.swing.JTextField();
commandTranslatedLabel = new javax.swing.JLabel();
commandTranslatedField = new javax.swing.JTextField();
statusLabel = new javax.swing.JLabel();
String[] modes = { "Not Seen", "Skipped", "Error" ,"Change" , "Accepted" , "Perfect" ,"Other"};
statusCombo = statusCombo = new JComboBox(modes);
commentLabel = new javax.swing.JLabel();
commentField = new javax.swing.JTextField();
translatedScroll = new javax.swing.JScrollPane();
translatedArea = new javax.swing.JTextArea();
buttonPanel = new javax.swing.JPanel();
okayButton = 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);
basicPanel.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints2;
basicPanel.setBorder(new javax.swing.border.TitledBorder(
new javax.swing.border.EtchedBorder(), "Basic information", 4, 2,
new java.awt.Font ("Dialog", 0, 10)));
InstallLabel.setText("Install");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.insets = new java.awt.Insets(3, 0, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
basicPanel.add(InstallLabel, gridBagConstraints2);
installField.setEditable(false);
installField.setColumns(15);
installField.setText("The Install");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints2.weightx = 1.0;
basicPanel.add(installField, gridBagConstraints2);
componentLabel.setText("Component");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 2;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
basicPanel.add(componentLabel, gridBagConstraints2);
componentField.setEditable(false);
componentField.setColumns(15);
componentField.setText("The Component");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 3;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints2.weightx = 1.0;
basicPanel.add(componentField, gridBagConstraints2);
fileLabel.setText("File");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 2;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
basicPanel.add(fileLabel, gridBagConstraints2);
fileField.setEditable(false);
fileField.setColumns(15);
fileField.setText("The File");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 3;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints2.weightx = 1.0;
basicPanel.add(fileField, gridBagConstraints2);
keyLabel.setText("Key");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 2;
gridBagConstraints2.insets = new java.awt.Insets(3, 0, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
basicPanel.add(keyLabel, gridBagConstraints2);
keyField.setEditable(false);
keyField.setColumns(15);
keyField.setText("The key");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 2;
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints2.weightx = 1.0;
basicPanel.add(keyField, gridBagConstraints2);
subcomponentLabel.setText("Subcomponent");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.insets = new java.awt.Insets(3, 0, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
basicPanel.add(subcomponentLabel, gridBagConstraints2);
subcomponentField.setEditable(false);
subcomponentField.setColumns(15);
subcomponentField.setText("the subcomponent");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints2.weightx = 1.0;
basicPanel.add(subcomponentField, gridBagConstraints2);
accessConnectLabel.setText("Accesskey");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 2;
gridBagConstraints2.gridy = 3;
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
basicPanel.add(accessConnectLabel, gridBagConstraints2);
accessConnectField.setEditable(false);
accessConnectField.setColumns(15);
accessConnectField.setText("somenameAccesskey");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 3;
gridBagConstraints2.gridy = 3;
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
basicPanel.add(accessConnectField, gridBagConstraints2);
commandConnectLabel.setText("Commandkey");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 3;
gridBagConstraints2.insets = new java.awt.Insets(3, 0, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
basicPanel.add(commandConnectLabel, gridBagConstraints2);
commandConnectField.setEditable(false);
commandConnectField.setColumns(15);
commandConnectField.setText("yada yadaComandKey");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 3;
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
basicPanel.add(commandConnectField, gridBagConstraints2);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;
getContentPane().add(basicPanel, gridBagConstraints1);
orignalPanel.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints3;
orignalPanel.setBorder(new javax.swing.border.TitledBorder(
new javax.swing.border.EtchedBorder(), "Original", 4, 2,
new java.awt.Font ("Dialog", 0, 10)));
textLabel.setText("Text");
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.insets = new java.awt.Insets(5, 0, 0, 0);
gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHEAST;
orignalPanel.add(textLabel, gridBagConstraints3);
keepLabel.setText("Filter");
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 2;
gridBagConstraints3.insets = new java.awt.Insets(3, 0, 0, 0);
gridBagConstraints3.anchor = java.awt.GridBagConstraints.EAST;
orignalPanel.add(keepLabel, gridBagConstraints3);
keepCheck.setText("Keep original text");
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 1;
gridBagConstraints3.gridy = 2;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints3.anchor = java.awt.GridBagConstraints.WEST;
orignalPanel.add(keepCheck, gridBagConstraints3);
noteLabel.setText("Loc. note");
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 1;
gridBagConstraints3.insets = new java.awt.Insets(5, 0, 0, 0);
gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHEAST;
orignalPanel.add(noteLabel, gridBagConstraints3);
originalArea.setEditable(false);
originalArea.setColumns(25);
originalArea.setRows(3);
originalArea.setText("This is bogus text\nShould newer show\ncheers\nHenrik\n");
originalScroll.setViewportView(originalArea);
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 1;
gridBagConstraints3.gridy = 0;
gridBagConstraints3.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints3.insets = new java.awt.Insets(3, 3, 0, 0);
orignalPanel.add(originalScroll, gridBagConstraints3);
noteArea.setEditable(false);
noteArea.setColumns(25);
noteArea.setRows(3);
noteArea.setText("this is bogus text\nshould newr show\ncheers \nhenrik");
noteScroll.setViewportView(noteArea);
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 1;
gridBagConstraints3.gridy = 1;
gridBagConstraints3.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints3.insets = new java.awt.Insets(3, 3, 0, 0);
orignalPanel.add(noteScroll, gridBagConstraints3);
accessOriginalLabel.setText("Accesskey");
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 3;
gridBagConstraints3.insets = new java.awt.Insets(3, 0, 0, 0);
gridBagConstraints3.anchor = java.awt.GridBagConstraints.EAST;
orignalPanel.add(accessOriginalLabel, gridBagConstraints3);
acessOriginalField.setEditable(false);
acessOriginalField.setColumns(10);
acessOriginalField.setText("jTextField1");
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 1;
gridBagConstraints3.gridy = 3;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHWEST;
orignalPanel.add(acessOriginalField, gridBagConstraints3);
commandOriginalLabel.setText("commandkey");
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 4;
gridBagConstraints3.insets = new java.awt.Insets(3, 0, 0, 0);
gridBagConstraints3.anchor = java.awt.GridBagConstraints.EAST;
orignalPanel.add(commandOriginalLabel, gridBagConstraints3);
commandOriginalField.setEditable(false);
commandOriginalField.setColumns(10);
commandOriginalField.setText("jTextField2");
gridBagConstraints3 = new java.awt.GridBagConstraints();
gridBagConstraints3.gridx = 1;
gridBagConstraints3.gridy = 4;
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints3.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints3.anchor = java.awt.GridBagConstraints.WEST;
orignalPanel.add(commandOriginalField, gridBagConstraints3);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;
getContentPane().add(orignalPanel, gridBagConstraints1);
translatedPanel.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints4;
translatedPanel.setBorder(new javax.swing.border.TitledBorder(
new javax.swing.border.EtchedBorder(), "Translated", 4, 2,
new java.awt.Font ("Dialog", 0, 10)));
translatedLabel.setText("Text");
gridBagConstraints4 = new java.awt.GridBagConstraints();
gridBagConstraints4.gridx = 0;
gridBagConstraints4.gridy = 0;
gridBagConstraints4.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTHEAST;
translatedPanel.add(translatedLabel, gridBagConstraints4);
accessTranslatedLabel.setText("Accesskey");
gridBagConstraints4 = new java.awt.GridBagConstraints();
gridBagConstraints4.gridx = 0;
gridBagConstraints4.gridy = 1;
gridBagConstraints4.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints4.anchor = java.awt.GridBagConstraints.WEST;
translatedPanel.add(accessTranslatedLabel, gridBagConstraints4);
accessTranslatedField.setColumns(10);
accessTranslatedField.setText("jTextField1");
gridBagConstraints4 = new java.awt.GridBagConstraints();
gridBagConstraints4.gridx = 1;
gridBagConstraints4.gridy = 1;
gridBagConstraints4.gridwidth = 0;
gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints4.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints4.anchor = java.awt.GridBagConstraints.WEST;
translatedPanel.add(accessTranslatedField, gridBagConstraints4);
commandTranslatedLabel.setText("Commandkey");
gridBagConstraints4 = new java.awt.GridBagConstraints();
gridBagConstraints4.gridx = 0;
gridBagConstraints4.gridy = 2;
gridBagConstraints4.anchor = java.awt.GridBagConstraints.WEST;
translatedPanel.add(commandTranslatedLabel, gridBagConstraints4);
commandTranslatedField.setColumns(10);
commandTranslatedField.setText("jTextField2");
gridBagConstraints4 = new java.awt.GridBagConstraints();
gridBagConstraints4.gridx = 1;
gridBagConstraints4.gridy = 2;
gridBagConstraints4.gridwidth = 0;
gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints4.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints4.anchor = java.awt.GridBagConstraints.WEST;
translatedPanel.add(commandTranslatedField, gridBagConstraints4);
statusLabel.setText("Status");
gridBagConstraints4 = new java.awt.GridBagConstraints();
gridBagConstraints4.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints4.anchor = java.awt.GridBagConstraints.WEST;
translatedPanel.add(statusLabel, gridBagConstraints4);
gridBagConstraints4 = new java.awt.GridBagConstraints();
gridBagConstraints4.gridwidth = 0;
gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints4.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints4.anchor = java.awt.GridBagConstraints.WEST;
translatedPanel.add(statusCombo, gridBagConstraints4);
commentLabel.setText("Comment");
gridBagConstraints4 = new java.awt.GridBagConstraints();
gridBagConstraints4.gridx = 0;
gridBagConstraints4.gridy = 4;
gridBagConstraints4.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints4.anchor = java.awt.GridBagConstraints.WEST;
translatedPanel.add(commentLabel, gridBagConstraints4);
commentField.setColumns(15);
commentField.setText("some comment");
gridBagConstraints4 = new java.awt.GridBagConstraints();
gridBagConstraints4.gridx = 1;
gridBagConstraints4.gridy = 4;
gridBagConstraints4.gridwidth = 0;
gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints4.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints4.anchor = java.awt.GridBagConstraints.WEST;
translatedPanel.add(commentField, gridBagConstraints4);
translatedArea.setColumns(25);
translatedArea.setRows(3);
translatedArea.setText("this is bogus text\nshould newer show\ncheers\nhenrik\n");
translatedScroll.setViewportView(translatedArea);
gridBagConstraints4 = new java.awt.GridBagConstraints();
gridBagConstraints4.gridx = 1;
gridBagConstraints4.gridy = 0;
gridBagConstraints4.gridwidth = 0;
gridBagConstraints4.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints4.insets = new java.awt.Insets(3, 3, 0, 0);
translatedPanel.add(translatedScroll, gridBagConstraints4);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 1;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;
getContentPane().add(translatedPanel, gridBagConstraints1);
buttonPanel.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints5;
okayButton.setMnemonic('O');
okayButton.setText("Okay");
okayButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okayButtonPressed(evt);
}
}
);
gridBagConstraints5 = new java.awt.GridBagConstraints();
gridBagConstraints5.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints5.anchor = java.awt.GridBagConstraints.EAST;
buttonPanel.add(okayButton, gridBagConstraints5);
cancelButton.setMnemonic('C');
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonPressed(evt);
}
}
);
gridBagConstraints5 = new java.awt.GridBagConstraints();
gridBagConstraints5.gridx = 1;
gridBagConstraints5.gridy = 0;
gridBagConstraints5.gridwidth = 0;
gridBagConstraints5.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints5.anchor = java.awt.GridBagConstraints.EAST;
buttonPanel.add(cancelButton, gridBagConstraints5);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 2;
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;
getContentPane().add(buttonPanel, gridBagConstraints1);
}//GEN-END:initComponents
private void cancelButtonPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonPressed
okay=false;
setVisible(false);
}//GEN-LAST:event_cancelButtonPressed
private void okayButtonPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okayButtonPressed
okay=true;
setVisible(false);
}//GEN-LAST:event_okayButtonPressed
public void visDialog(Phrase phrase,String localeName)
{
MozInstall install;
MozComponent component;
MozComponent subcomponent;
MozFile file;
Translation translation;
Phrase accessPhrase,commandPhrase;
Translation accessTranslation,commandTranslation;
// fetch the needed objects
file = (MozFile) phrase.getParent();
subcomponent = (MozComponent) file.getParent();
component = (MozComponent) subcomponent.getParent();
install = (MozInstall) component.getParent();
translation = (Translation) phrase.getChildByName(localeName);
accessPhrase = phrase.getAccessConnection();
commandPhrase = phrase.getCommandConnection();
accessTranslation=null;
commandTranslation=null;
// set up the connections
if (accessPhrase!=null)
{
accessTranslation = (Translation) accessPhrase.getChildByName(localeName);
accessConnectField.setText(accessPhrase.getName());
if (accessTranslation!=null)
{
accessTranslatedField.setText(accessTranslation.getText());
}
else
{
accessTranslatedField.setText("");
}
acessOriginalField.setText(accessPhrase.getText());
}
else
{
accessConnectField.setText("Nothing found");
accessTranslatedField.setText("");
accessTranslatedLabel.setEnabled(false);
accessTranslatedField.setEnabled(false);
acessOriginalField.setEnabled(false);
acessOriginalField.setText("");
}
if (commandPhrase!=null)
{
commandTranslation = (Translation) commandPhrase.getChildByName(localeName);
commandConnectField.setText(commandPhrase.getName());
if (commandTranslation!=null)
{
commandTranslatedField.setText(commandTranslation.getText());
}
else
{
commandTranslatedField.setText("");
}
commandOriginalField.setText(commandPhrase.getText());
}
else
{
commandConnectField.setText("Nothing found");
commandTranslatedField.setText("");
commandTranslatedLabel.setEnabled(false);
commandTranslatedField.setEnabled(false);
commandOriginalField.setText("");
commandOriginalField.setEnabled(false);
}
// basic information
installField.setText(install.getName());
componentField.setText(component.getName());
subcomponentField.setText(subcomponent.getName());
fileField.setText(file.getName());
keyField.setText(phrase.getName());
//original information
originalArea.setText(phrase.getText());
noteArea.setText(phrase.getNote());
keepCheck.setSelected(phrase.getKeepOriginal());
originalArea.setCaretPosition(0);
noteArea.setCaretPosition(0);
// translated information
if (translation!=null)
{
translatedArea.setText(translation.getText());
statusCombo.setSelectedIndex(translation.getStatus());
commentField.setText(translation.getComment());
}
else
{
translatedArea.setText("");
statusCombo.setSelectedIndex(0);
commentField.setText("");
}
okay=false;
translatedArea.setCaretPosition(0);
setVisible(true);
// set the new information if neededd
if (okay)
{
if (translation!=null)
{
translation.setText(translatedArea.getText());
translation.setStatus(statusCombo.getSelectedIndex());
translation.setComment(commentField.getText());
}
else
{
translation = new Translation(localeName,phrase,translatedArea.getText(),statusCombo.getSelectedIndex(),commentField.getText());
phrase.addChild(translation);
}
// set the access connection if needed
if (accessTranslatedField.isEnabled())
{
if (accessTranslation!=null)
{
accessTranslation.setText(accessTranslatedField.getText());
}
else
{
accessTranslation = new Translation(localeName,accessPhrase,accessTranslatedField.getText());
accessPhrase.addChild(accessTranslation);
}
}
//set the command connection if needed
if (commandTranslatedField.isEnabled())
{
if (commandTranslation!=null)
{
commandTranslation.setText(commandTranslatedField.getText());
}
else
{
commandTranslation = new Translation(localeName,commandPhrase,commandTranslatedField.getText());
commandPhrase.addChild(commandTranslation);
}
}
}
dispose();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel basicPanel;
private javax.swing.JLabel InstallLabel;
private javax.swing.JTextField installField;
private javax.swing.JLabel componentLabel;
private javax.swing.JTextField componentField;
private javax.swing.JLabel fileLabel;
private javax.swing.JTextField fileField;
private javax.swing.JLabel keyLabel;
private javax.swing.JTextField keyField;
private javax.swing.JLabel subcomponentLabel;
private javax.swing.JTextField subcomponentField;
private javax.swing.JLabel accessConnectLabel;
private javax.swing.JTextField accessConnectField;
private javax.swing.JLabel commandConnectLabel;
private javax.swing.JTextField commandConnectField;
private javax.swing.JPanel orignalPanel;
private javax.swing.JLabel textLabel;
private javax.swing.JLabel keepLabel;
private javax.swing.JCheckBox keepCheck;
private javax.swing.JLabel noteLabel;
private javax.swing.JScrollPane originalScroll;
private javax.swing.JTextArea originalArea;
private javax.swing.JScrollPane noteScroll;
private javax.swing.JTextArea noteArea;
private javax.swing.JLabel accessOriginalLabel;
private javax.swing.JTextField acessOriginalField;
private javax.swing.JLabel commandOriginalLabel;
private javax.swing.JTextField commandOriginalField;
private javax.swing.JPanel translatedPanel;
private javax.swing.JLabel translatedLabel;
private javax.swing.JLabel accessTranslatedLabel;
private javax.swing.JTextField accessTranslatedField;
private javax.swing.JLabel commandTranslatedLabel;
private javax.swing.JTextField commandTranslatedField;
private javax.swing.JLabel statusLabel;
private javax.swing.JComboBox statusCombo;
private javax.swing.JLabel commentLabel;
private javax.swing.JTextField commentField;
private javax.swing.JScrollPane translatedScroll;
private javax.swing.JTextArea translatedArea;
private javax.swing.JPanel buttonPanel;
private javax.swing.JButton okayButton;
private javax.swing.JButton cancelButton;
// End of variables declaration//GEN-END:variables
private boolean okay;
}

View File

@ -0,0 +1,296 @@
/*
* 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.util.*;
import javax.swing.*;
import java.io.*;
import org.mozilla.translator.gui.*;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.kernel.*;
/**
*
* @author Henrik
* @version
*/
public class ExportPartialGlossaryDialog extends javax.swing.JDialog
{
/** Creates new form ExportPartialGlossaryDialoh */
public ExportPartialGlossaryDialog() {
super (MainWindow.getDefaultInstance(),"Export partial glossary",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
buttonPanel = new javax.swing.JPanel ();
okButton = new javax.swing.JButton ();
cancelButton = new javax.swing.JButton ();
infoPanel = new javax.swing.JPanel ();
installLabel = new javax.swing.JLabel ();
installCombo = installCombo = new JComboBox(Glossary.getDefaultInstance().toArray());
subcomponentLabel = new javax.swing.JLabel ();
fileLabel = new javax.swing.JLabel ();
fileField = new javax.swing.JTextField ();
fileButton = new javax.swing.JButton ();
listScroll = new javax.swing.JScrollPane ();
subcomponentList = subcomponentList = new JList(getSubs());
setDefaultCloseOperation (javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
okButton.setText ("OK");
okButton.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
okButtonActionPerformed (evt);
}
}
);
buttonPanel.add (okButton);
cancelButton.setText ("Cancel");
cancelButton.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed (evt);
}
}
);
buttonPanel.add (cancelButton);
getContentPane ().add (buttonPanel, java.awt.BorderLayout.SOUTH);
infoPanel.setLayout (new java.awt.GridBagLayout ());
java.awt.GridBagConstraints gridBagConstraints1;
infoPanel.setBorder (new javax.swing.border.TitledBorder(
new javax.swing.border.EtchedBorder(), "Information", 4, 2,
new java.awt.Font ("Dialog", 0, 10)));
installLabel.setText ("Install");
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.insets = new java.awt.Insets (3, 3, 0, 0);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
infoPanel.add (installLabel, gridBagConstraints1);
installCombo.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
installComboActionPerformed (evt);
}
}
);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridx = 1;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.insets = new java.awt.Insets (3, 3, 0, 0);
infoPanel.add (installCombo, gridBagConstraints1);
subcomponentLabel.setText ("Subcomponents");
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 2;
gridBagConstraints1.insets = new java.awt.Insets (3, 3, 0, 0);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
infoPanel.add (subcomponentLabel, gridBagConstraints1);
fileLabel.setText ("File");
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.insets = new java.awt.Insets (3, 3, 0, 0);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
infoPanel.add (fileLabel, gridBagConstraints1);
fileField.setColumns (20);
fileField.setText ("I hate IE");
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridx = 1;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.insets = new java.awt.Insets (3, 3, 0, 0);
infoPanel.add (fileField, gridBagConstraints1);
fileButton.setText ("Choose");
fileButton.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
fileButtonActionPerformed (evt);
}
}
);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridx = 2;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.insets = new java.awt.Insets (3, 3, 0, 0);
infoPanel.add (fileButton, gridBagConstraints1);
subcomponentList.setPrototypeCellValue ("some very long subcomponent");
listScroll.setViewportView (subcomponentList);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridx = 1;
gridBagConstraints1.gridy = 2;
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.insets = new java.awt.Insets (3, 3, 0, 0);
infoPanel.add (listScroll, gridBagConstraints1);
getContentPane ().add (infoPanel, java.awt.BorderLayout.CENTER);
}//GEN-END:initComponents
private void cancelButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
okay=false;
setVisible(false);
}//GEN-LAST:event_cancelButtonActionPerformed
private void okButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
okay=true;
setVisible(false);
}//GEN-LAST:event_okButtonActionPerformed
private void fileButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileButtonActionPerformed
File defaultFile = new File(fileField.getText());
JFileChooser dirChooser = new JFileChooser();
dirChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
dirChooser.setDialogTitle("Select file to export to");
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_fileButtonActionPerformed
private void installComboActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_installComboActionPerformed
subcomponentList.setListData(getSubs());
}//GEN-LAST:event_installComboActionPerformed
/** Closes the dialog */
public Object[] getSubs()
{
Iterator componentIterator;
MozComponent currentComponent;
List result = new ArrayList();
MozInstall install = (MozInstall) installCombo.getSelectedItem();
componentIterator = install.getChildIterator();
while (componentIterator.hasNext())
{
currentComponent = (MozComponent) componentIterator.next();
result.addAll(currentComponent.getAllChildren());
}
return result.toArray();
}
public boolean visDialog()
{
MozInstall preSelect;
fileField.setText(Settings.getString("saved.fileName.partial.export",""));
preSelect = (MozInstall) Glossary.getDefaultInstance().getChildByName(Settings.getString("saved.install",""));
if (preSelect!=null)
{
installCombo.setSelectedItem(preSelect);
subcomponentList.setListData(getSubs());
}
setVisible(true);
if (okay)
{
Settings.setString("saved.fileName.partial.export",fileField.getText());
Settings.setString("saved.install",installCombo.getSelectedItem().toString());
}
return okay;
}
public String getFileName()
{
return fileField.getText();
}
public MozInstall getInstall()
{
return (MozInstall) installCombo.getSelectedItem();
}
public Object[] getSubcomponents()
{
Object obj;
Object[] result = subcomponentList.getSelectedValues();
for (int i=0;i<result.length;i++)
{
obj = result[i];
}
return result;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel buttonPanel;
private javax.swing.JButton okButton;
private javax.swing.JButton cancelButton;
private javax.swing.JPanel infoPanel;
private javax.swing.JLabel installLabel;
private javax.swing.JComboBox installCombo;
private javax.swing.JLabel subcomponentLabel;
private javax.swing.JLabel fileLabel;
private javax.swing.JTextField fileField;
private javax.swing.JButton fileButton;
private javax.swing.JScrollPane listScroll;
private javax.swing.JList subcomponentList;
// End of variables declaration//GEN-END:variables
private boolean okay;
}

View File

@ -0,0 +1,244 @@
/*
* 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 ImportGlossaryDialog extends javax.swing.JDialog {
private boolean old;
/** Creates new form ImportOldGlossaryDialog */
public ImportGlossaryDialog(String title,boolean oldImport) {
super (MainWindow.getDefaultInstance(),title,true);
initComponents ();
getRootPane().setDefaultButton(okButton);
pack ();
old=oldImport;
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());
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 ("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);
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);
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_ONLY);
dirChooser.setDialogTitle("Select glossary 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;
if (!old)
{
fileField.setText(Settings.getString("saved.fileName.partial.import",""));
}
else
{
fileField.setText("");
}
preSelect = (MozInstall) Glossary.getDefaultInstance().getChildByName(Settings.getString("saved.install",""));
if (preSelect!=null)
{
installCombo.setSelectedItem(preSelect);
}
setVisible(true);
if (okay)
{
if (!old)
{
Settings.setString("saved.fileName.partial.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();
}
// 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.JButton okButton;
private javax.swing.JButton cancelButton;
// End of variables declaration//GEN-END:variables
private boolean okay;
}

View File

@ -0,0 +1,226 @@
/*
* 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 javax.swing.*;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.gui.*;
import org.mozilla.translator.datamodel.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version
*/
public class InstallAdminDialog extends javax.swing.JDialog {
/** Creates new form InstallAdmin */
public InstallAdminDialog(java.awt.Frame parent) {
super (parent,"Install configuration", true);
initComponents ();
getRootPane().setDefaultButton(exitButton);
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
exitButton = new javax.swing.JButton ();
listPanel = new javax.swing.JPanel ();
listScroll = new javax.swing.JScrollPane ();
installList = new javax.swing.JList ();
addButton = new javax.swing.JButton ();
editButton = new javax.swing.JButton ();
removeButton = new javax.swing.JButton ();
getContentPane ().setLayout (new java.awt.GridBagLayout ());
java.awt.GridBagConstraints gridBagConstraints1;
setResizable (false);
setDefaultCloseOperation (javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener (new java.awt.event.WindowAdapter () {
public void windowClosing (java.awt.event.WindowEvent evt) {
closeWindow (evt);
}
}
);
exitButton.setToolTipText ("Leave the dialogbox");
exitButton.setText ("Exit");
exitButton.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
exitButtonPressed (evt);
}
}
);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.insets = new java.awt.Insets (0, 3, 3, 3);
getContentPane ().add (exitButton, gridBagConstraints1);
listPanel.setLayout (new java.awt.GridBagLayout ());
java.awt.GridBagConstraints gridBagConstraints2;
listPanel.setBorder (new javax.swing.border.TitledBorder(
new javax.swing.border.EtchedBorder(), "Known installations", 4, 2,
new java.awt.Font ("Dialog", 0, 10)));
installList.setModel (Glossary.getDefaultInstance());
installList.setPrototypeCellValue ("netscape 60 Preview Release 10 ");
listScroll.setViewportView (installList);
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridheight = 3;
gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints2.insets = new java.awt.Insets (3, 3, 3, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
listPanel.add (listScroll, gridBagConstraints2);
addButton.setToolTipText ("Add a new Mozilla installation");
addButton.setText ("Add");
addButton.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
addButtonPressed (evt);
}
}
);
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 3, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
listPanel.add (addButton, gridBagConstraints2);
editButton.setToolTipText ("Edit the selected Mozilla installation");
editButton.setText ("Edit");
editButton.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
editButtonPressed (evt);
}
}
);
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.insets = new java.awt.Insets (0, 0, 3, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
listPanel.add (editButton, gridBagConstraints2);
removeButton.setToolTipText ("Remove the selected Mozilla installation");
removeButton.setText ("Remove");
removeButton.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
removeButtonPressed (evt);
}
}
);
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 2;
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.insets = new java.awt.Insets (0, 0, 3, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
listPanel.add (removeButton, gridBagConstraints2);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.insets = new java.awt.Insets (3, 3, 3, 3);
getContentPane ().add (listPanel, gridBagConstraints1);
}//GEN-END:initComponents
private void closeWindow (java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeWindow
setVisible(false);
dispose();
}//GEN-LAST:event_closeWindow
private void exitButtonPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonPressed
setVisible(false);
dispose();
}//GEN-LAST:event_exitButtonPressed
private void removeButtonPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonPressed
MozInstall install = (MozInstall) installList.getSelectedValue();
int result;
result = JOptionPane.showConfirmDialog(removeButton,"Really remove: " + install,"Remove Installation",JOptionPane.OK_CANCEL_OPTION,JOptionPane.WARNING_MESSAGE);
if (result==JOptionPane.OK_OPTION)
{
Glossary.getDefaultInstance().removeChild(install);
Glossary.getDefaultInstance().fireContentsChanged();
}
}//GEN-LAST:event_removeButtonPressed
private void editButtonPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonPressed
boolean junk;
MozInstall install = (MozInstall) installList.getSelectedValue();
EditInstallDialog eid= new EditInstallDialog(MainWindow.getDefaultInstance(),install);
if (eid.visDialog())
{
Glossary.getDefaultInstance().fireContentsChanged();
}
}//GEN-LAST:event_editButtonPressed
private void addButtonPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonPressed
MozInstall install = new MozInstall("","");
EditInstallDialog eid = new EditInstallDialog(MainWindow.getDefaultInstance(),install);
if (eid.visDialog())
{
Glossary.getDefaultInstance().addChild(install);
Glossary.getDefaultInstance().fireContentsChanged();
}
}//GEN-LAST:event_addButtonPressed
/** Closes the dialog */
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton exitButton;
private javax.swing.JPanel listPanel;
private javax.swing.JScrollPane listScroll;
private javax.swing.JList installList;
private javax.swing.JButton addButton;
private javax.swing.JButton editButton;
private javax.swing.JButton removeButton;
// End of variables declaration//GEN-END:variables
}

View File

@ -0,0 +1,284 @@
/*
* 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 org.mozilla.translator.kernel.*;
/**
*
* @author Henrik Lynggaard
* @version 3.4
*/
public class SearchDialog extends javax.swing.JDialog {
private String searchText;
private String localeName;
private String selectedColumn;
private String selectedRule;
private boolean selectedCase;
private boolean okay;
/** Creates new form SearchDialog */
public SearchDialog(java.awt.Frame parent,boolean modal) {
super (parent, "Search",modal);
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
searchLabel = new javax.swing.JLabel();
searchField = new javax.swing.JTextField();
WhereLabel = new javax.swing.JLabel();
columnCombo = new javax.swing.JComboBox();
ruleCombo = new javax.swing.JComboBox();
localeLabel = new javax.swing.JLabel();
localeField = new javax.swing.JTextField();
okButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
howLabel = new javax.swing.JLabel();
caseCheck = new javax.swing.JCheckBox();
getContentPane().setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
searchLabel.setText("Search for ");
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.insets = new java.awt.Insets(3, 0, 0, 0);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
getContentPane().add(searchLabel, gridBagConstraints1);
searchField.setText("x");
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.insets = new java.awt.Insets(3, 3, 0, 0);
getContentPane().add(searchField, gridBagConstraints1);
WhereLabel.setText("Where");
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.insets = new java.awt.Insets(3, 0, 0, 0);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
getContentPane().add(WhereLabel, gridBagConstraints1);
columnCombo.addItem("Key");
columnCombo.addItem("Localization note");
columnCombo.addItem("Original text");
columnCombo.addItem("Translated text");
columnCombo.addItem("QA comment");
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 1;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.insets = new java.awt.Insets(3, 3, 0, 0);
getContentPane().add(columnCombo, gridBagConstraints1);
ruleCombo.addItem("Is");
ruleCombo.addItem("Is not");
ruleCombo.addItem("Contains");
ruleCombo.addItem("Doesn't contain");
ruleCombo.addItem("Starts with");
ruleCombo.addItem("Ends with");
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 1;
gridBagConstraints1.gridy = 2;
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.insets = new java.awt.Insets(3, 3, 0, 0);
getContentPane().add(ruleCombo, gridBagConstraints1);
localeLabel.setText("Locale");
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 3;
gridBagConstraints1.insets = new java.awt.Insets(3, 0, 0, 0);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
getContentPane().add(localeLabel, gridBagConstraints1);
localeField.setText("da-DK");
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 1;
gridBagConstraints1.gridy = 3;
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.insets = new java.awt.Insets(3, 3, 0, 0);
getContentPane().add(localeField, gridBagConstraints1);
okButton.setText("OK");
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okPressed(evt);
}
}
);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 5;
gridBagConstraints1.insets = new java.awt.Insets(3, 0, 0, 0);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST;
getContentPane().add(okButton, gridBagConstraints1);
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelPressed(evt);
}
}
);
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 1;
gridBagConstraints1.gridy = 5;
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.insets = new java.awt.Insets(3, 2, 0, 0);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
getContentPane().add(cancelButton, gridBagConstraints1);
howLabel.setText("how");
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 2;
gridBagConstraints1.insets = new java.awt.Insets(3, 0, 0, 0);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
getContentPane().add(howLabel, gridBagConstraints1);
caseCheck.setSelected(true);
caseCheck.setText("Casesensitive");
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridx = 1;
gridBagConstraints1.gridy = 4;
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.insets = new java.awt.Insets(3, 3, 0, 0);
getContentPane().add(caseCheck, gridBagConstraints1);
}//GEN-END:initComponents
private void okPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okPressed
okay=true;
setVisible(false);
}//GEN-LAST:event_okPressed
private void cancelPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelPressed
okay=false;
setVisible(false);
}//GEN-LAST:event_cancelPressed
public boolean visDialog()
{
okay=false;
localeField.setText(Settings.getString("saved.localeName",""));
searchField.setText(Settings.getString("saved.search.text",""));
columnCombo.setSelectedIndex(Settings.getInteger("saved.search.field",0));
ruleCombo.setSelectedIndex(Settings.getInteger("saved.search.rule",0));
caseCheck.setSelected(Settings.getBoolean("saved.search.case",false));
setVisible(true);
if (okay)
{
Settings.setString("saved.localeName",localeField.getText());
Settings.setString("saved.search.text",searchField.getText());
Settings.setInteger("saved.search.field",columnCombo.getSelectedIndex());
Settings.setInteger("saved.search.rule",ruleCombo.getSelectedIndex());
Settings.setBoolean("saved.search.case",caseCheck.isSelected());
}
searchText = searchField.getText();
localeName = localeField.getText();
selectedColumn = columnCombo.getSelectedItem().toString();
selectedRule = ruleCombo.getSelectedItem().toString();
selectedCase = caseCheck.isSelected();
dispose();
return okay;
}
public String getSearchText() { return searchText; }
public String getLocaleName() { return localeName; }
public String getColumn() { return selectedColumn;}
public String getRule() { return selectedRule;}
public boolean getCase() { return selectedCase;}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel searchLabel;
private javax.swing.JTextField searchField;
private javax.swing.JLabel WhereLabel;
private javax.swing.JComboBox columnCombo;
private javax.swing.JComboBox ruleCombo;
private javax.swing.JLabel localeLabel;
private javax.swing.JTextField localeField;
private javax.swing.JButton okButton;
private javax.swing.JButton cancelButton;
private javax.swing.JLabel howLabel;
private javax.swing.JCheckBox caseCheck;
// End of variables declaration//GEN-END:variables
}

View File

@ -0,0 +1,232 @@
/*
* 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 org.mozilla.translator.kernel.*;
import org.mozilla.translator.gui.*;
/**
*
* @author Henrik
* @version
*/
public class SetupDialog extends javax.swing.JDialog {
/** Creates new form SetupDialog */
public SetupDialog() {
super (MainWindow.getDefaultInstance(),"Setup MozillaTranslator",true);
initComponents ();
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
tabbedPane = new javax.swing.JTabbedPane();
generalTab = new javax.swing.JPanel();
localeLabel = new javax.swing.JLabel();
localeField = new javax.swing.JTextField();
packageTab = new javax.swing.JPanel();
authorLabel = new javax.swing.JLabel();
authorField = new javax.swing.JTextField();
displayLabel = new javax.swing.JLabel();
displayField = new javax.swing.JTextField();
previewLabel = new javax.swing.JLabel();
previewField = new javax.swing.JTextField();
jPanel1 = new javax.swing.JPanel();
okButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
generalTab.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints1;
localeLabel.setText("Default locale");
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.insets = new java.awt.Insets(3, 0, 0, 0);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;
generalTab.add(localeLabel, gridBagConstraints1);
localeField.setColumns(15);
localeField.setText("da-DK");
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;
generalTab.add(localeField, gridBagConstraints1);
tabbedPane.addTab("General", generalTab);
packageTab.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints2;
authorLabel.setText("Author");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.insets = new java.awt.Insets(3, 0, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
packageTab.add(authorLabel, gridBagConstraints2);
authorField.setColumns(20);
authorField.setText("Henrik Lynggaard");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
packageTab.add(authorField, gridBagConstraints2);
displayLabel.setText("Display name");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.insets = new java.awt.Insets(3, 0, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
packageTab.add(displayLabel, gridBagConstraints2);
displayField.setColumns(20);
displayField.setText("Danish Localization");
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(3, 3, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
packageTab.add(displayField, gridBagConstraints2);
previewLabel.setText("Preview URL");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 2;
gridBagConstraints2.insets = new java.awt.Insets(3, 0, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
packageTab.add(previewLabel, gridBagConstraints2);
previewField.setColumns(30);
previewField.setText("http://www.mozilla.org/previews/da-DK.gif");
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 2;
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets(3, 3, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
packageTab.add(previewField, gridBagConstraints2);
tabbedPane.addTab("Package", packageTab);
getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER);
okButton.setText("OK");
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonPressed(evt);
}
}
);
jPanel1.add(okButton);
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonPressed(evt);
}
}
);
jPanel1.add(cancelButton);
getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH);
}//GEN-END:initComponents
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 void visDialog()
{
// setup the dialog
localeField.setText(Settings.getString("saved.localeName",""));
authorField.setText(Settings.getString("Package.Author",""));
displayField.setText(Settings.getString("Package.Display",""));
previewField.setText(Settings.getString("Package.Preview",""));
// show dialog
okay=false;
setVisible(true);
if (okay)
{
Settings.setString("Locale.Defaultguess",localeField.getText());
Settings.setString("Package.Author",authorField.getText());
Settings.setString("Package.Display",displayField.getText());
Settings.setString("Package.Preview",previewField.getText());
Settings.save();
}
dispose();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTabbedPane tabbedPane;
private javax.swing.JPanel generalTab;
private javax.swing.JLabel localeLabel;
private javax.swing.JTextField localeField;
private javax.swing.JPanel packageTab;
private javax.swing.JLabel authorLabel;
private javax.swing.JTextField authorField;
private javax.swing.JLabel displayLabel;
private javax.swing.JTextField displayField;
private javax.swing.JLabel previewLabel;
private javax.swing.JTextField previewField;
private javax.swing.JPanel jPanel1;
private javax.swing.JButton okButton;
private javax.swing.JButton cancelButton;
// End of variables declaration//GEN-END:variables
private boolean okay;
}

View File

@ -0,0 +1,254 @@
/*
* 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.util.*;
import javax.swing.*;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.gui.models.*;
import org.mozilla.translator.gui.*;
/**
*
* @author Henrik
* @version
*/
public class ShowWhatDialog extends javax.swing.JDialog
{
/** Creates new form ShowWhatDialog */
public ShowWhatDialog()
{
super (MainWindow.getDefaultInstance(),"Show what ?", true);
initComponents ();
getRootPane().setDefaultButton(okButton);
pack ();
Utils.placeFrameAtCenter(this);
}
public void disableLocaleField()
{
localeField.setEnabled(false);
}
/** 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
jPanel1 = new javax.swing.JPanel ();
localeLabel = new javax.swing.JLabel ();
localeField = new javax.swing.JTextField ();
InstallLabel = new javax.swing.JLabel ();
installScroll = new javax.swing.JScrollPane ();
java.util.List colList = new ArrayList();
colList.add(new ComplexColumn(ComplexColumn.FIELD_INSTALL));
colList.add(new ComplexColumn(ComplexColumn.FIELD_COMPONENT));
colList.add(new ComplexColumn(ComplexColumn.FIELD_SUBCOMPONENT));
colList.add(new ComplexColumn(ComplexColumn.FIELD_FILE));
colList.add(new ComplexColumn(ComplexColumn.FIELD_KEY));
colList.add(new ComplexColumn(ComplexColumn.FIELD_ORIGINAL_TEXT));
colList.add(new ComplexColumn(ComplexColumn.FIELD_ORIGINAL_ACCESSKEY));
colList.add(new ComplexColumn(ComplexColumn.FIELD_ORIGINAL_COMMANDKEY));
colList.add(new ComplexColumn(ComplexColumn.FIELD_NOTE));
colList.add(new ComplexColumn(ComplexColumn.FIELD_KEEP));
colList.add(new ComplexColumn(ComplexColumn.FIELD_TRANSLATED_TEXT));
colList.add(new ComplexColumn(ComplexColumn.FIELD_TRANSLATED_ACCESSKEY));
colList.add(new ComplexColumn(ComplexColumn.FIELD_TRANSLATED_COMMANDKEY));
colList.add(new ComplexColumn(ComplexColumn.FIELD_QACOMMENT));
colList.add(new ComplexColumn(ComplexColumn.FIELD_QASTATUS));
colList.add(new ComplexColumn(ComplexColumn.FIELD_CURRENT_TEXT));
colList.add(new ComplexColumn(ComplexColumn.FIELD_CURRENT_ACCESSKEY));
colList.add(new ComplexColumn(ComplexColumn.FIELD_CURRENT_COMMANDKEY));
installList = new JList(colList.toArray());
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);
jPanel1.setLayout (new java.awt.GridBagLayout ());
java.awt.GridBagConstraints gridBagConstraints2;
jPanel1.setBorder (new javax.swing.border.TitledBorder(
new javax.swing.border.EtchedBorder(), "Show what", 4, 2,
new java.awt.Font ("Dialog", 0, 10)));
localeLabel.setText ("Locale");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.insets = new java.awt.Insets (3, 3, 3, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
jPanel1.add (localeLabel, gridBagConstraints2);
localeField.setColumns (10);
localeField.setText ("da-DK");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 3, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
jPanel1.add (localeField, gridBagConstraints2);
InstallLabel.setText ("columns");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.insets = new java.awt.Insets (0, 3, 0, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
jPanel1.add (InstallLabel, gridBagConstraints2);
installList.setPrototypeCellValue (" Localization note ");
installList.setVisibleRowCount (15);
installScroll.setViewportView (installList);
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 1;
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.insets = new java.awt.Insets (0, 0, 3, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
jPanel1.add (installScroll, gridBagConstraints2);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.insets = new java.awt.Insets (3, 3, 3, 3);
getContentPane ().add (jPanel1, 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);
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);
getContentPane ().add (cancelButton, gridBagConstraints1);
}//GEN-END:initComponents
private void cancelButtonPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonPressed
okay=false;
setVisible(false);
}//GEN-LAST:event_cancelButtonPressed
private void okButtonPressed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonPressed
okay=true;
setVisible(false);
}//GEN-LAST:event_okButtonPressed
public boolean visDialog()
{
int[] selectedFromStart;
ListSelectionModel lsm;
Object[] installs = Glossary.getDefaultInstance().toArray();
MozInstall install = (MozInstall) installs[0];
localeField.setText(Settings.getString("saved.localeName",""));
okay=false;
lsm = installList.getSelectionModel();
for (int i=0;i<18;i++)
{
if (Settings.getBoolean("saved.column." + i,false))
{
lsm.addSelectionInterval(i,i);
}
}
setVisible(true);
if (okay)
{
Settings.setString("saved.localeName",localeField.getText());
for (int i=0;i<18;i++)
{
Settings.setBoolean("saved.column." + i,false);
}
selectedFromStart = installList.getSelectedIndices();
for (int i=0;i<selectedFromStart.length;i++)
{
Settings.setBoolean("saved.column." + selectedFromStart[i],true);
}
}
return okay;
}
public List getSelectedColumns()
{
Object[] arrayResult = installList.getSelectedValues();
List listResult;
listResult = Arrays.asList(arrayResult);
return listResult;
}
public String getSelectedLocale()
{
return localeField.getText();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel localeLabel;
private javax.swing.JTextField localeField;
private javax.swing.JLabel InstallLabel;
private javax.swing.JScrollPane installScroll;
private javax.swing.JList installList;
private javax.swing.JButton okButton;
private javax.swing.JButton cancelButton;
// End of variables declaration//GEN-END:variables
private boolean okay;
}

View File

@ -0,0 +1,339 @@
/*
* 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 WritePackageDialog extends javax.swing.JDialog {
/** Creates new form ImportOldGlossaryDialog */
public WritePackageDialog() {
super (MainWindow.getDefaultInstance(),"Write package",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 ();
authorLabel = new javax.swing.JLabel ();
authorField = new javax.swing.JTextField ();
displayLabel = new javax.swing.JLabel ();
displayField = new javax.swing.JTextField ();
previewLabel = new javax.swing.JLabel ();
previewField = 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 ("Save to");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 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.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 3);
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, 0, 0);
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 (3, 0, 0, 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 (3, 0, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infPanel.add (installCombo, gridBagConstraints2);
localeLabel.setText ("Locale");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infPanel.add (localeLabel, gridBagConstraints2);
localeField.setColumns (10);
localeField.setText ("da-DK");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infPanel.add (localeField, gridBagConstraints2);
authorLabel.setText ("Author");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infPanel.add (authorLabel, gridBagConstraints2);
authorField.setColumns (30);
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 0);
infPanel.add (authorField, gridBagConstraints2);
displayLabel.setText ("Display name");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 4;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infPanel.add (displayLabel, gridBagConstraints2);
displayField.setColumns (30);
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 4;
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 0);
infPanel.add (displayField, gridBagConstraints2);
previewLabel.setText ("Preview URL");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 5;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infPanel.add (previewLabel, gridBagConstraints2);
previewField.setColumns (30);
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 5;
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 0);
infPanel.add (previewField, 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.DIRECTORIES_ONLY);
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 install = (MozInstall) installCombo.getSelectedItem();
fileField.setText(Settings.getString("saved.Writepackage.File",""));
localeField.setText(Settings.getString("saved.localeName",""));
authorField.setText(Settings.getString("saved.author",""));
displayField.setText(Settings.getString("saved.displayName",""));
previewField.setText(Settings.getString("saved.previewURL",""));
setVisible(true);
if (okay)
{
Settings.setString("saved.Writepackage.File",fileField.getText());
Settings.setString("saved.localeName",localeField.getText());
Settings.setString("saved.author",authorField.getText());
Settings.setString("saved.displayName",displayField.getText());
Settings.setString("saved.previewURL",previewField.getText());
}
return okay;
}
public String getFile()
{
return fileField.getText();
}
public MozInstall getInstall()
{
return (MozInstall) installCombo.getSelectedItem();
}
public String getLocaleName()
{
return localeField.getText();
}
public String getAuthor()
{
return authorField.getText();
}
public String getDisplay()
{
return displayField.getText();
}
public String getPreview()
{
return previewField.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.JLabel authorLabel;
private javax.swing.JTextField authorField;
private javax.swing.JLabel displayLabel;
private javax.swing.JTextField displayField;
private javax.swing.JLabel previewLabel;
private javax.swing.JTextField previewField;
private javax.swing.JButton okButton;
private javax.swing.JButton cancelButton;
// End of variables declaration//GEN-END:variables
private boolean okay;
}

View File

@ -0,0 +1,364 @@
/*
* 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 WriteXpiDialog extends javax.swing.JDialog {
/** Creates new form ImportOldGlossaryDialog */
public WriteXpiDialog() {
super (MainWindow.getDefaultInstance(),"Write XPI",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 ();
authorLabel = new javax.swing.JLabel ();
authorField = new javax.swing.JTextField ();
displayLabel = new javax.swing.JLabel ();
displayField = new javax.swing.JTextField ();
previewLabel = new javax.swing.JLabel ();
previewField = new javax.swing.JTextField ();
versionLabel = new javax.swing.JLabel ();
versionField = 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 ("Save to");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 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.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 3);
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, 0, 0);
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 (3, 0, 0, 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 (3, 0, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infPanel.add (installCombo, gridBagConstraints2);
localeLabel.setText ("Locale");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infPanel.add (localeLabel, gridBagConstraints2);
localeField.setColumns (10);
localeField.setText ("da-DK");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infPanel.add (localeField, gridBagConstraints2);
authorLabel.setText ("Author");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infPanel.add (authorLabel, gridBagConstraints2);
authorField.setColumns (30);
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 0);
infPanel.add (authorField, gridBagConstraints2);
displayLabel.setText ("Display name");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 4;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infPanel.add (displayLabel, gridBagConstraints2);
displayField.setColumns (30);
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 4;
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 0);
infPanel.add (displayField, gridBagConstraints2);
previewLabel.setText ("Preview URL");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridy = 5;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infPanel.add (previewLabel, gridBagConstraints2);
previewField.setColumns (30);
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridx = 1;
gridBagConstraints2.gridy = 5;
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 0);
infPanel.add (previewField, gridBagConstraints2);
versionLabel.setText ("Version");
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 3);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
infPanel.add (versionLabel, gridBagConstraints2);
versionField.setColumns (30);
gridBagConstraints2 = new java.awt.GridBagConstraints ();
gridBagConstraints2.gridwidth = 0;
gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new java.awt.Insets (3, 0, 0, 0);
infPanel.add (versionField, 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_ONLY);
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 install = (MozInstall) installCombo.getSelectedItem();
fileField.setText(Settings.getString("saved.xpiFile",""));
localeField.setText(Settings.getString("saved.localeName",""));
authorField.setText(Settings.getString("saved.author",""));
displayField.setText(Settings.getString("saved.displayName",""));
previewField.setText(Settings.getString("saved.previewURL",""));
versionField.setText(Settings.getString("saved.xpiVersion",""));
setVisible(true);
if (okay)
{
Settings.setString("saved.xpiFile",fileField.getText());
Settings.setString("saved.localeName",localeField.getText());
Settings.setString("saved.author",authorField.getText());
Settings.setString("saved.displayName",displayField.getText());
Settings.setString("saved.previewURL",previewField.getText());
Settings.setString("saved.xpiVersion",versionField.getText());
}
return okay;
}
public String getFile()
{
return fileField.getText();
}
public MozInstall getInstall()
{
return (MozInstall) installCombo.getSelectedItem();
}
public String getLocaleName()
{
return localeField.getText();
}
public String getAuthor()
{
return authorField.getText();
}
public String getDisplay()
{
return displayField.getText();
}
public String getPreview()
{
return previewField.getText();
}
public String getVersion()
{
return versionField.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.JLabel authorLabel;
private javax.swing.JTextField authorField;
private javax.swing.JLabel displayLabel;
private javax.swing.JTextField displayField;
private javax.swing.JLabel previewLabel;
private javax.swing.JTextField previewField;
private javax.swing.JLabel versionLabel;
private javax.swing.JTextField versionField;
private javax.swing.JButton okButton;
private javax.swing.JButton cancelButton;
// End of variables declaration//GEN-END:variables
private boolean okay;
}

View File

@ -0,0 +1,522 @@
/*
* 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.models;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.kernel.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version 4.0
*/
public class ComplexColumn extends Object {
public static final int FIELD_INSTALL=1;
public static final int FIELD_COMPONENT=2;
public static final int FIELD_SUBCOMPONENT=3;
public static final int FIELD_FILE=4;
public static final int FIELD_KEY=5;
public static final int FIELD_ORIGINAL_TEXT=6;
public static final int FIELD_NOTE=7;
public static final int FIELD_KEEP=8;
public static final int FIELD_TRANSLATED_TEXT=9;
public static final int FIELD_QASTATUS=10;
public static final int FIELD_QACOMMENT=11;
public static final int FIELD_TRANSLATED_ACCESSKEY=12;
public static final int FIELD_TRANSLATED_COMMANDKEY=13;
public static final int FIELD_ORIGINAL_ACCESSKEY=14;
public static final int FIELD_ORIGINAL_COMMANDKEY=15;
public static final int FIELD_CURRENT_TEXT=16;
public static final int FIELD_CURRENT_ACCESSKEY=17;
public static final int FIELD_CURRENT_COMMANDKEY=18;
private static Class bclass;
private static Class iclass;
private static Class sclass;
private int field;
public static void init()
{
try
{
bclass = Class.forName("java.lang.Boolean");
iclass = Class.forName("java.lang.Integer");
sclass = Class.forName("java.lang.String");
}
catch (Exception e)
{
Log.write("Error initializing complexcolumn data");
}
}
/** Creates new ComplexColumn */
public ComplexColumn(int f)
{
field=f;
}
public int getField()
{
return field;
}
public String getName()
{
String result="";
switch (field)
{
case FIELD_INSTALL:
result ="Install";
break;
case FIELD_COMPONENT:
result="Component";
break;
case FIELD_SUBCOMPONENT:
result="Subcomponent";
break;
case FIELD_FILE:
result="File";
break;
case FIELD_KEY:
result="Key";
break;
case FIELD_ORIGINAL_TEXT:
result="Org. Text";
break;
case FIELD_NOTE:
result="Localization note";
break;
case FIELD_KEEP:
result="Keep";
break;
case FIELD_TRANSLATED_TEXT:
result="Translated Text";
break;
case FIELD_QASTATUS:
result="QA status";
break;
case FIELD_QACOMMENT:
result="QA comment";
break;
case FIELD_ORIGINAL_ACCESSKEY:
result="Org. accessKey";
break;
case FIELD_ORIGINAL_COMMANDKEY:
result="Org. commandKey";
break;
case FIELD_TRANSLATED_ACCESSKEY:
result ="Translated accesskey";
break;
case FIELD_TRANSLATED_COMMANDKEY:
result = "Translated commandkey";
break;
case FIELD_CURRENT_TEXT:
result = "Current text";
break;
case FIELD_CURRENT_ACCESSKEY:
result = "Current accesskey";
break;
case FIELD_CURRENT_COMMANDKEY:
result = "Current commandkey";
break;
}
return result;
}
public Class getColumnClass()
{
Class result=null;
switch (field)
{
case FIELD_INSTALL:
case FIELD_COMPONENT:
case FIELD_SUBCOMPONENT:
case FIELD_FILE:
case FIELD_KEY:
case FIELD_ORIGINAL_TEXT:
case FIELD_NOTE:
case FIELD_TRANSLATED_TEXT:
case FIELD_QACOMMENT:
case FIELD_ORIGINAL_ACCESSKEY:
case FIELD_ORIGINAL_COMMANDKEY:
case FIELD_TRANSLATED_ACCESSKEY:
case FIELD_TRANSLATED_COMMANDKEY:
case FIELD_CURRENT_TEXT:
case FIELD_CURRENT_ACCESSKEY:
case FIELD_CURRENT_COMMANDKEY:
result = sclass;
break;
case FIELD_KEEP:
result = bclass;
break;
case FIELD_QASTATUS:
result = iclass;
}
return result;
}
public boolean isEditable(Phrase p,String localeName)
{
boolean result=false;
switch (field)
{
case FIELD_INSTALL:
case FIELD_COMPONENT:
case FIELD_SUBCOMPONENT:
case FIELD_FILE:
case FIELD_KEY:
case FIELD_ORIGINAL_TEXT:
case FIELD_ORIGINAL_ACCESSKEY:
case FIELD_ORIGINAL_COMMANDKEY:
result=false;
break;
case FIELD_NOTE:
case FIELD_KEEP:
result=true;
break;
case FIELD_TRANSLATED_TEXT:
case FIELD_CURRENT_TEXT:
if (p.getKeepOriginal())
{
result=false;
}
else
{
result=true;
}
break;
case FIELD_QACOMMENT:
case FIELD_QASTATUS:
if (p.getChildByName(localeName)!=null)
{
result=true;
}
else
{
result=false;
}
break;
case FIELD_TRANSLATED_ACCESSKEY:
case FIELD_CURRENT_ACCESSKEY:
if (p.getAccessConnection()!=null)
{
result=true;
}
else
{
result=false;
}
break;
case FIELD_TRANSLATED_COMMANDKEY:
case FIELD_CURRENT_COMMANDKEY:
if (p.getCommandConnection()!=null)
{
result=true;
}
else
{
result=false;
}
break;
}
return result;
}
public Object getValue(Phrase p,String localeName)
{
Object result=null;
MozInstall install;
MozComponent component;
MozFile file;
Phrase otherPhrase;
Translation trans;
switch (field)
{
case FIELD_INSTALL:
result = p.getParent().getParent().getParent().getParent().toString();
break;
case FIELD_COMPONENT:
result = p.getParent().getParent().getParent().toString();
break;
case FIELD_SUBCOMPONENT:
result = p.getParent().getParent().toString();
break;
case FIELD_FILE:
result = p.getParent().toString();
break;
case FIELD_KEY:
result = p.getName();
break;
case FIELD_ORIGINAL_TEXT:
result = p.getText();
break;
case FIELD_NOTE:
result = p.getNote();
break;
case FIELD_KEEP:
result = new Boolean(p.getKeepOriginal());
break;
case FIELD_ORIGINAL_ACCESSKEY:
result="";
otherPhrase = p.getAccessConnection();
if (otherPhrase!=null)
{
result= otherPhrase.getText();
}
break;
case FIELD_TRANSLATED_ACCESSKEY:
result="";
otherPhrase = p.getAccessConnection();
if (otherPhrase!=null)
{
trans= (Translation) otherPhrase.getChildByName(localeName);
if (trans!=null)
{
result=trans.getText();
}
}
break;
case FIELD_CURRENT_ACCESSKEY:
result="";
otherPhrase = p.getAccessConnection();
if (otherPhrase!=null)
{
trans= (Translation) otherPhrase.getChildByName(localeName);
if (trans!=null)
{
result=trans.getText();
}
else
{
result=otherPhrase.getText();
}
}
break;
case FIELD_ORIGINAL_COMMANDKEY:
result="";
otherPhrase = p.getCommandConnection();
if (otherPhrase!=null)
{
result= otherPhrase.getText();
}
break;
case FIELD_TRANSLATED_COMMANDKEY:
result="";
otherPhrase = p.getCommandConnection();
if (otherPhrase!=null)
{
trans= (Translation) otherPhrase.getChildByName(localeName);
if (trans!=null)
{
result=trans.getText(); // get the translated version
}
}
break;
case FIELD_CURRENT_COMMANDKEY:
result="";
otherPhrase = p.getCommandConnection();
if (otherPhrase!=null)
{
trans= (Translation) otherPhrase.getChildByName(localeName);
if (trans!=null)
{
result=trans.getText();
}
else
{
result=otherPhrase.getText();
}
}
break;
case FIELD_TRANSLATED_TEXT:
result="";
trans = (Translation) p.getChildByName(localeName);
if (trans!=null)
{
result = trans.getText();
}
break;
case FIELD_CURRENT_TEXT:
result="";
trans = (Translation) p.getChildByName(localeName);
if (trans!=null)
{
result = trans.getText();
}
else
{
result = p.getText();
}
break;
case FIELD_QASTATUS:
trans = (Translation) p.getChildByName(localeName);
if (trans!=null)
{
result = new Integer(trans.getStatus());
}
else
{
result = new Integer(Translation.QA_NOTSEEN);
}
break;
case FIELD_QACOMMENT:
result="";
trans = (Translation) p.getChildByName(localeName);
if (trans!=null)
{
result = trans.getText();
}
break;
}
return result;
}
public void setValue(Phrase p,Object value,String localeName)
{
String strValue;
Boolean boolValue;
Integer intValue;
Translation pair;
Phrase otherPhrase;
switch (field)
{
case FIELD_NOTE:
p.setNote(value.toString());
break;
case FIELD_KEEP:
boolValue = (Boolean) value;
p.setKeepOriginal(boolValue.booleanValue());
break;
case FIELD_TRANSLATED_TEXT:
case FIELD_CURRENT_TEXT:
strValue = (String) value;
if (!strValue.equals(""))
{
pair = (Translation) p.getChildByName(localeName);
if (pair==null)
{
pair = new Translation(localeName,p,strValue);
p.addChild(pair);
}
else
{
pair.setText(strValue);
}
}
else
{
p.removeChild(p.getChildByName(localeName));
}
break;
case FIELD_QASTATUS:
intValue = (Integer) value;
pair = (Translation) p.getChildByName(localeName);
if (pair!=null)
{
pair.setStatus(intValue.intValue());
}
break;
case FIELD_QACOMMENT:
strValue = (String) value;
pair = (Translation) p.getChildByName(localeName);
if (pair!=null)
{
pair.setComment(strValue);
}
break;
case FIELD_TRANSLATED_ACCESSKEY:
case FIELD_CURRENT_ACCESSKEY:
strValue = (String) value;
otherPhrase = p.getAccessConnection();
if (otherPhrase!=null)
{
if (!strValue.equals(""))
{
pair = (Translation) otherPhrase.getChildByName(localeName);
if (pair==null)
{
pair = new Translation(localeName,otherPhrase,strValue);
otherPhrase.addChild(pair);
}
else
{
pair.setText(strValue);
}
}
else
{
otherPhrase.removeChild(otherPhrase.getChildByName(localeName));
}
}
break;
case FIELD_TRANSLATED_COMMANDKEY:
case FIELD_CURRENT_COMMANDKEY:
strValue = (String) value;
otherPhrase = p.getCommandConnection();
if (otherPhrase!=null)
{
if (!strValue.equals(""))
{
pair = (Translation) otherPhrase.getChildByName(localeName);
if (pair==null)
{
pair = new Translation(localeName,otherPhrase,strValue);
otherPhrase.addChild(pair);
}
else
{
pair.setText(strValue);
}
}
else
{
otherPhrase.removeChild(otherPhrase.getChildByName(localeName));
}
}
break;
}
}
public String toString()
{
return getName();
}
}

View File

@ -0,0 +1,122 @@
/*
* 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.models;
import java.util.*;
import javax.swing.table.*;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.kernel.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version 4.0
*/
public class ComplexTableModel extends AbstractTableModel {
private List phrases;
private List columns;
private int rows;
private int cols;
private ComplexColumn cc;
private String localeName;
/** Creates new ComplexTableModel */
public ComplexTableModel(List toModel,List toCols,String lName)
{
phrases = toModel;
columns = toCols;
localeName=lName;
rows = phrases.size();
cols = columns.size();
}
public int getRowCount()
{
return rows;
}
public int getColumnCount()
{
return cols;
}
public String getColumnName(int index)
{
String result;
cc = (ComplexColumn) columns.get(index);
result = cc.getName();
return result;
}
public Class getColumnClass(int index)
{
Class result;
cc = (ComplexColumn) columns.get(index);
result = cc.getColumnClass();
return result;
}
public boolean isCellEditable(int rowIndex,int columnIndex)
{
cc = (ComplexColumn) columns.get(columnIndex);
Phrase ph = (Phrase) phrases.get(rowIndex);
return cc.isEditable(ph,localeName);
}
public Object getValueAt(int rowIndex,int columnIndex)
{
cc = (ComplexColumn) columns.get(columnIndex);
Phrase ph = (Phrase) phrases.get(rowIndex);
return cc.getValue(ph,localeName);
}
public void setValueAt(Object aValue,int rowIndex,int columnIndex)
{
cc = (ComplexColumn) columns.get(columnIndex);
Phrase ph = (Phrase) phrases.get(rowIndex);
cc.setValue(ph,aValue,localeName);
}
public String getLocaleName()
{
return localeName;
}
public Phrase getRow(int index)
{
return (Phrase) phrases.get(index);
}
}

View File

@ -0,0 +1,106 @@
Blue sky:
+ Client/server version with automatiation
Todo:
+ define command line commands :-)
+ fix XPI install.js error
+ remember state on all dialogs (where is it missing?)
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
MozillaTranslator 4.1
+ Rewrite of datamodel and io subsystems
+ Preparations for command line control
+ More status display on loading/saving of glossary
+ More status display on loading/saving of partial glossary
+ More status display on update install
+ "case (in)sensitive" setting in Search now remembered (bugfix)
- Removed the reading of loccalization notes. The reason is that they where buggy
and in preparation for moving to a real XML parser
+ More status on import old glossary (properly not really needed)
+ More status on write package
MozillaTranslator 4.01
+ Added support for Case (in)sensitive switch in search
+ new View : redundant Strings
+ redone state remembering
+ Made Settings take default values (internal stuff)
MozillaTranslator 4
* changed keep original title to "keep" in order to reduce column space needed
* XPI eksport
* keyBinding checker
* New Columns
* original accesskey READ ONLY
* original commandkey READ ONLY
* translated accesskey (same as the previus accesskey) READ/WRITE
* translated commandkey (same as the preview commandkay) READ/WRITE
* current text (the translated text if any, otherwise the original text) READ/WRITE
* current accesskey (the translated accesskey if any, otherwise the original accesskey) READ/WRITE
* current commandkey (the translated commandkey if any, otherwise the original commandkey) READ/WRITE
* changed the deafult ordering of the columns
* simple search implemented
* OK is now default button and can be activated by pressing enter (if a textArea hasn't got focus)
MozillaTranslator 4 RC - 2
+ added accesskey og commandkey original info in editPhrase
+ i think i fixed the "edits in edit phrase dialog" sometimes isn't saved bug
+ made the text areas in the dit phrase dialog open at the first characters
+ fixed the accesskey and commmandkey coloum to return blank when no translation
+ Fixed bug in Import Partial Glossary, that made it abort erly and only read some of the strings
+ Fixed bug that allways sat the keep original flag, now flag is only set on new phrases
MozillaTranslator 4 RC-1
+ Added export partial glossary
+ enabled the import partial glossary
+ fixed the reading of DTD files
+ added insert of licence information
+ write Package now remembers where it was saved last
MozillaTranslator 4 beta 6b
+ fixed overwriteing of unspupported files
MozillaTranslator 4 beta 6
+ Fixed "glossary file" label in writePackage Dialog
+ fixed missing locale subdir in writePackage runner
MozillaTranslator 4 beta 5
+ Finished the hookeing up of accesskey /commandkey
+ Made the edit dialog much nicer (thanx kairo)
- disabled import of partial glossary for until there is a export, since the file is NOT compatible with version 3.x
+ Begun Setup Dialog
MozillaTranslator 4 beta 4
+ Added Write Package that writes a localization and the manifest.rdf file
+ Import of partial glossary files
+ partial hooked up the Label -> accessKey/commandkey functionality
+ initial edit dialog
MozillaTranslator 4 beta 3
+ added save Glossary
+ Added chrome view
+ added Import old glossary file
Mozilla translator 4 (beta 1+2 internal milestones)
+ added support for the new chrome directory structure
+ added support for multiple installs

View File

@ -0,0 +1,327 @@
/*
* 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 org.mozilla.translator.datamodel.*;
import org.mozilla.translator.kernel.*;
/**
*
* @author Henrik
* @version
*/
public class DTDReader extends MozFileReader {
private static final int STATUS_COMMENT_WAITING=1;
private static final int STATUS_COMMENT_BEGUN=2;
private static final int STATUS_COMMENT_JUMP=3;
private static final int STATUS_COMMENT_SCOPE=4;
private static final int STATUS_COMMENT_NOTE=5;
private static final int STATUS_ENTITY_KEY=6;
private static final int STATUS_ENTITY_TEXT=7;
private static final int SCOPE_FILE=1;
private static final int SCOPE_BLOCK=2;
private static final int SCOPE_KEY=3;
private static final String TOKEN_ENTITY="!ENTITY";
private static final String TOKEN_COMMENT="!--";
private static final String TOKEN_LOCNOTE="LOCALIZATION";
private static final String TOKEN_BEGINBLOCK="BEGIN";
private static final String TOKEN_ENDBLOCK="END";
private InputStreamReader isr;
private BufferedReader br;
private boolean globalDone;
private String key,text;
public DTDReader(MozFile f,InputStream i)
{
super(f,i);
}
public void readFile(String localeName) throws IOException
{
boolean done;
Phrase currentPhrase;
Translation currentTranslation;
isr = new InputStreamReader(is,"UTF-8");
br = new BufferedReader(isr);
globalDone=false;
while (!globalDone)
{
readNextEntry(localeName);
if (!key.equals(""))
{
currentPhrase = (Phrase) fil.getChildByName(key);
if (localeName.equalsIgnoreCase("en-us"))
{
if (currentPhrase==null)
{
currentPhrase= new Phrase(key,fil,text,"",false);
fil.addChild(currentPhrase);
}
else
{
currentPhrase.setText(text);
}
currentPhrase.setMarked(true);
}
else
{
if (currentPhrase!=null)
{
currentTranslation = (Translation) currentPhrase.getChildByName(localeName);
if (currentTranslation==null)
{
currentTranslation = new Translation(localeName,currentPhrase,text);
currentPhrase.addChild(currentTranslation);
}
else
{
currentTranslation.setText(text);
}
}
}
}
}
}
public void readNextEntry(String localeName)
{
int number;
StringBuffer segmentBuffer;
boolean entityBegun;
char letter;
boolean entryDone;
boolean endResult;
entryDone=false;
segmentBuffer =null;
entityBegun=false;
while (!entryDone)
{
number = readNextChar();
if (number!=-1)
{
letter = (char) number;
if (entityBegun==true)
{
segmentBuffer.append(letter);
if (segmentBuffer.toString().equalsIgnoreCase(TOKEN_COMMENT))
{
readComment();
entityBegun=false;
}
else if (segmentBuffer.toString().equalsIgnoreCase(TOKEN_ENTITY))
{
readEntity();
entryDone=true;
}
else if (letter=='>')
{
entityBegun=false;
}
}
else
{
if (letter=='<')
{
entityBegun=true;
segmentBuffer = new StringBuffer();
}
}
}
else
{
entryDone=true;
globalDone=true;
}
}
}
public void readEntity()
{
boolean keyBegun;
boolean textBegun;
boolean more;
int status,number;
char letter,endChar;
StringBuffer entityBuffer=null;
status = STATUS_ENTITY_KEY;
keyBegun = false;
textBegun = false;
more=true;
endChar='z';
while (more)
{
number = readNextChar();
if (number!=-1)
{
letter = (char) number;
switch (status)
{
case STATUS_ENTITY_KEY:
if (keyBegun)
{
if (letter==' ' || letter=='\t')
{
key = entityBuffer.toString();
status = STATUS_ENTITY_TEXT;
textBegun=false;
}
else
{
entityBuffer.append(letter);
}
}
else
{
if (letter!=' ' && letter!='\t')
{
keyBegun= true;
entityBuffer= new StringBuffer();
}
}
break;
case STATUS_ENTITY_TEXT:
if (textBegun)
{
if (letter==endChar)
{
text = entityBuffer.toString();
readSkip();
more=false;
}
else
{
entityBuffer.append(letter);
}
}
else
{
if (letter=='\"' || letter=='\'')
{
textBegun=true;
entityBuffer= new StringBuffer();
endChar=letter;
}
}
break;
}
}
else
{
globalDone=true;
more=false;
}
}
}
private void readComment()
{
readSkip();
}
private void readSkip()
{
boolean more;
int number;
char letter;
more=true;
while (more)
{
number = readNextChar();
if (number!=-1)
{
letter = (char) number;
if (letter=='>')
{
more=false;
}
}
else
{
more=false;
globalDone=true;
}
}
}
private int readNextChar()
{
int number;
try
{
number = br.read();
}
catch (Exception e)
{
Log.write("Error during reading dtd file");
Log.write("Exception: " + e);
number=-1;
}
return number;
}
public void close()
{
try
{
br.close();
}
catch (Exception e)
{
Log.write("Error closing read DTD file");
Log.write("Exception "+e);
}
}
}

View File

@ -0,0 +1,97 @@
/*
* 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.*;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.datamodel.*;
/** This class writes *.dtd files in the mozilla Chrome
* @author Henrik Lynggaard Hansen
* @version 3.0
*/
public class DTDWriter extends MozFileWriter
{
private static String header ="<!-- Translated with MozillaTranslator " + Settings.getString("System.Version","(unknown version)") + " -->";
/** Creates new DTDWriter
* @param os The output stream to write to
*/
public DTDWriter(MozFile f,OutputStream o)
{
super(f,o);
}
public void writeFile(String localeName) throws IOException
{
OutputStreamWriter osw;
BufferedWriter bw;
Iterator phraseIterator;
Phrase currentPhrase;
Translation currentTranslation;
String key,text,line;
osw = new OutputStreamWriter(os,"UTF-8");
bw = new BufferedWriter(osw);
bw.write(header);
bw.newLine();
phraseIterator = fil.getChildIterator();
while (phraseIterator.hasNext())
{
currentPhrase = (Phrase) phraseIterator.next();
key = currentPhrase.getName();
currentTranslation = (Translation) currentPhrase.getChildByName(localeName);
if (currentTranslation==null || localeName.equals("en-us"))
{
text = currentPhrase.getText();
}
else
{
text = currentTranslation.getText();
}
if (text.indexOf("\"")==-1)
{
line = "<!ENTITY " +key +" \"" + text +"\">";
}
else
{
line = "<!ENTITY " +key +" '" + text +"'>";
}
bw.write(line,0,line.length());
bw.newLine();
}
bw.close();
}
}

View File

@ -0,0 +1,373 @@
/*
* GlossaryAccess.java
*
* Created on 27. august 2000, 17:03
*/
package org.mozilla.translator.io;
import java.io.*;
import java.util.*;
import java.util.zip.*;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.gui.*;
/**
*
* @author Henrik Lynggaard
* @version
*/
public class GlossaryAccess implements MozInstallAccess {
/** Creates new GlossaryAccess */
public GlossaryAccess()
{
// empty
}
public void load()
{
FileInputStream fis;
ZipInputStream zis;
ZipEntry ze;
int installMax,installCount;
int componentMax,componentCount;
int subcomponentMax,subcomponentCount;
int fileMax,fileCount;
int phraseMax,phraseCount;
int translationMax,translationCount;
String installPrefix;
String componentPrefix;
String subcomponentPrefix;
String filePrefix;
String phrasePrefix;
String translationPrefix;
MozInstall currentInstall;
MozComponent currentComponent;
MozComponent currentSubcomponent;
MozFile currentFile;
Phrase currentPhrase,labelPhrase,accessPhrase,commandPhrase;
Translation currentTranslation;
Properties prop;
String name;
String path;
String locale;
String key;
String note;
String text;
boolean keep;
String access;
String command;
Phrase accessLink;
Phrase commandLink;
String comment;
int status;
String statusPrefix,statusText;
MainWindow vindue = MainWindow.getDefaultInstance();
try
{
vindue.setStatus("Loading file");
prop= new Properties();
fis = new FileInputStream(Settings.getString("System.Glossaryfile","glossary.zip"));
zis = new ZipInputStream(fis);
ze = zis.getNextEntry();
prop.load(zis);
zis.closeEntry();
zis.close();
installMax = Integer.parseInt(prop.getProperty("install.count"));
for (installCount=0;installCount<installMax;installCount++)
{
statusPrefix = "Parsing install " + (installCount+1) + " of " + installMax + " : ";
installPrefix= "" + installCount + ".";
name = prop.getProperty(installPrefix + "name","");
path = prop.getProperty(installPrefix + "path","");
componentMax = Integer.parseInt(prop.getProperty(installPrefix + "count","0"));
currentInstall = new MozInstall(name,path);
Glossary.getDefaultInstance().addChild(currentInstall);
for (componentCount=0;componentCount<componentMax;componentCount++)
{
componentPrefix=installPrefix + componentCount + ".";
name = prop.getProperty(componentPrefix + "name","");
statusText = statusPrefix + "Component " + (componentCount+1) + " of " +componentMax + " ( " + name + ")";
vindue.setStatus(statusText);
subcomponentMax = Integer.parseInt(prop.getProperty(componentPrefix + "count","0"));
currentComponent = new MozComponent(name,currentInstall);
currentInstall.addChild(currentComponent);
for (subcomponentCount=0;subcomponentCount<subcomponentMax;subcomponentCount++)
{
subcomponentPrefix = componentPrefix + subcomponentCount + ".";
name = prop.getProperty(subcomponentPrefix + "name","");
fileMax = Integer.parseInt(prop.getProperty(subcomponentPrefix + "count","0"));
currentSubcomponent = new MozComponent(name,currentComponent);
currentComponent.addChild(currentSubcomponent);
for (fileCount=0;fileCount<fileMax;fileCount++)
{
filePrefix = subcomponentPrefix + fileCount + ".";
name = prop.getProperty(filePrefix + "name","");
phraseMax = Integer.parseInt(prop.getProperty(filePrefix + "count","0"));
currentFile = new MozFile(name,currentSubcomponent);
currentSubcomponent.addChild(currentFile);
for (phraseCount=0;phraseCount<phraseMax;phraseCount++)
{
phrasePrefix = filePrefix + phraseCount + ".";
key = prop.getProperty(phrasePrefix + "key","");
note = prop.getProperty(phrasePrefix + "note","");
text = prop.getProperty(phrasePrefix + "text","");
keep = Boolean.valueOf(prop.getProperty(phrasePrefix + "keep")).booleanValue();
translationMax = Integer.parseInt(prop.getProperty(phrasePrefix + "count",""));
currentPhrase = new Phrase(key,currentFile,text,note,keep);
currentPhrase.setAccessConnection(null);
currentPhrase.setCommandConnection(null);
currentFile.addChild(currentPhrase);
if (key.endsWith(".label"))
{
accessPhrase = (Phrase) currentFile.getChildByName(key.substring(0,key.length()-6)+ ".accesskey" );
commandPhrase =(Phrase) currentFile.getChildByName(key.substring(0,key.length()-6)+ ".commandkey" );
currentPhrase.setAccessConnection(accessPhrase);
currentPhrase.setCommandConnection(commandPhrase);
}
if (key.endsWith(".accesskey"))
{
labelPhrase = (Phrase) currentFile.getChildByName(key.substring(0,key.length()-10)+ ".label" );
if (labelPhrase!=null)
{
labelPhrase.setAccessConnection(currentPhrase);
}
}
if (key.endsWith(".commandkey"))
{
labelPhrase = (Phrase) currentFile.getChildByName(key.substring(0,key.length()-11)+".label" );
if (labelPhrase!=null)
{
labelPhrase.setCommandConnection(currentPhrase);
}
}
for (translationCount=0;translationCount<translationMax;translationCount++)
{
translationPrefix = phrasePrefix + translationCount + ".";
name = prop.getProperty(translationPrefix + "name","");
comment = prop.getProperty(translationPrefix + "comment","");
text = prop.getProperty(translationPrefix + "text","");
status = Integer.parseInt(prop.getProperty(translationPrefix + "status","0"));
currentTranslation = new Translation(name,currentPhrase,text,status,comment);
currentPhrase.addChild(currentTranslation);
}
}
}
}
}
}
MainWindow.getDefaultInstance().setStatus("Ready");
}
catch (Exception e)
{
Log.write("Exception : " +e);
Log.write("Error loading the glossary file");
}
}
public void save()
{
FileOutputStream fos;
ZipOutputStream zos;
ZipEntry ze;
Glossary glos;
MozInstall currentInstall;
MozComponent currentComponent;
MozComponent currentSubcomponent;
MozFile currentFile;
Phrase currentPhrase;
Translation currentTranslation;
Iterator installIterator;
Iterator componentIterator;
Iterator subcomponentIterator;
Iterator fileIterator;
Iterator phraseIterator;
Iterator translationIterator;
int installCount;
int componentCount;
int subcomponentCount;
int fileCount;
int phraseCount;
int translationCount;
String installPrefix;
String componentPrefix;
String subcomponentPrefix;
String filePrefix;
String phrasePrefix;
String translationPrefix;
String statusPrefix,statusText;
Properties prop;
MainWindow vindue = MainWindow.getDefaultInstance();
prop = new Properties();
installCount=0;
installIterator = Glossary.getDefaultInstance().getChildIterator();
while (installIterator.hasNext())
{
installPrefix = "" + installCount + ".";
currentInstall = (MozInstall) installIterator.next();
prop.setProperty(installPrefix + "name",currentInstall.getName());
prop.setProperty(installPrefix + "path",currentInstall.getPath());
componentIterator = currentInstall.getChildIterator();
componentCount=0;
statusPrefix = "Parsing install " + (installCount+1) + " : ";
while (componentIterator.hasNext())
{
componentPrefix = installPrefix + componentCount + ".";
currentComponent = (MozComponent) componentIterator.next();
statusText = statusPrefix + "Component " + (componentCount+1) + " ( " + currentComponent.getName() + ")";
vindue.setStatus(statusText);
prop.setProperty(componentPrefix +"name",currentComponent.getName());
subcomponentIterator = currentComponent.getChildIterator();
subcomponentCount = 0;
while (subcomponentIterator.hasNext())
{
subcomponentPrefix = componentPrefix + subcomponentCount + ".";
currentSubcomponent = (MozComponent) subcomponentIterator.next();
prop.setProperty(subcomponentPrefix + "name",currentSubcomponent.getName());
fileIterator = currentSubcomponent.getChildIterator();
fileCount =0;
while (fileIterator.hasNext())
{
filePrefix = subcomponentPrefix + fileCount + ".";
currentFile = (MozFile) fileIterator.next();
prop.setProperty(filePrefix + "name",currentFile.getName());
phraseIterator = currentFile.getChildIterator();
phraseCount=0;
while (phraseIterator.hasNext())
{
phrasePrefix = filePrefix + phraseCount + ".";
currentPhrase = (Phrase) phraseIterator.next();
prop.setProperty(phrasePrefix + "key",currentPhrase.getName());
prop.setProperty(phrasePrefix + "note",currentPhrase.getNote());
prop.setProperty(phrasePrefix + "text",currentPhrase.getText());
prop.setProperty(phrasePrefix + "keep",""+currentPhrase.getKeepOriginal());
translationIterator = currentPhrase.getChildIterator();
translationCount=0;
while (translationIterator.hasNext())
{
translationPrefix = phrasePrefix + translationCount + ".";
currentTranslation = (Translation) translationIterator.next();
prop.setProperty(translationPrefix + "name",currentTranslation.getName());
if (!currentTranslation.getComment().equals(""))
{
prop.setProperty(translationPrefix + "comment",currentTranslation.getComment());
}
prop.setProperty(translationPrefix + "text",currentTranslation.getText());
if (currentTranslation.getStatus()!=Translation.QA_NOTSEEN)
{
prop.setProperty(translationPrefix + "status",""+currentTranslation.getStatus());
}
translationCount++;
}
prop.setProperty(phrasePrefix + "count",""+translationCount);
phraseCount++;
}
prop.setProperty(filePrefix + "count",""+phraseCount);
fileCount++;
}
prop.setProperty(subcomponentPrefix + "count","" + fileCount);
subcomponentCount++;
}
prop.setProperty(componentPrefix + "count","" +subcomponentCount);
componentCount++;
}
prop.setProperty(installPrefix + "count",""+componentCount);
installCount++;
}
prop.setProperty("install.count","" + installCount);
try
{
vindue.setStatus("Saving file");
fos = new FileOutputStream(Settings.getString("System.Glossaryfile","glossary.zip"));
zos = new ZipOutputStream(fos);
ze = new ZipEntry("glossary.txt");
zos.putNextEntry(ze);
prop.store(zos,"Translated with MozillaTranslator " + Settings.getString("System.Version","(unknown version)"));
zos.closeEntry();
zos.close();
}
catch(Exception e)
{
Log.write("error writeing glossary file");
}
vindue.setStatus("Ready");
}
}

View File

@ -0,0 +1,47 @@
/*
* 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 org.mozilla.translator.datamodel.*;
/**
*
* @author Henrik Lynggaard
* @version 4.1
*/
public abstract class MozFileReader
{
protected MozFile fil;
protected InputStream is;
public MozFileReader(MozFile f,InputStream i)
{
fil = f;
is = i;
}
public abstract void readFile(String localeName) throws IOException;
}

View File

@ -0,0 +1,49 @@
/*
* 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 org.mozilla.translator.datamodel.*;
/**
*
* @author Henrik Lynggaard
* @version
*/
public abstract class MozFileWriter
{
protected MozFile fil;
protected OutputStream os;
public MozFileWriter(MozFile f,OutputStream o)
{
fil = f;
os =o;
}
public abstract void writeFile(String localeName) throws IOException;
}

View File

@ -0,0 +1,21 @@
/*
* MozInstallReader.java
*
* Created on 21. august 2000, 21:28
*/
package org.mozilla.translator.io;
import java.io.*;
/**
*
* @author Henrik Lynggaard
* @version
*/
public interface MozInstallAccess
{
public void load();
public void save();
}

View File

@ -0,0 +1,81 @@
/*
* 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 org.mozilla.translator.kernel.*;
import org.mozilla.translator.datamodel.*;
/**
*
* @author Henrik
* @version 4.0
*/
public class MozIo extends Object {
public static MozFileReader getFileReader(MozFile mfil,InputStream is)
{
MozFileReader result=null;
int type;
type = mfil.getType();
switch (type)
{
case MozFile.TYPE_DTD:
result = new DTDReader(mfil,is);
break;
case MozFile.TYPE_PROP:
result = new PropertiesReader(mfil,is);
break;
case MozFile.TYPE_UNSUPPORTED:
result = null;
break;
}
return result;
}
public static MozFileWriter getFileWriter(MozFile mfil,OutputStream os)
{
MozFileWriter result=null;
int type;
type = mfil.getType();
switch (type)
{
case MozFile.TYPE_DTD:
result = new DTDWriter(mfil,os);
break;
case MozFile.TYPE_PROP:
result = new PropertiesWriter(mfil,os);
break;
case MozFile.TYPE_UNSUPPORTED:
result = null;
break;
}
return result;
}
}

View File

@ -0,0 +1,260 @@
/*
* PartialAccess.java
*
* Created on 2. september 2000, 13:54
*/
package org.mozilla.translator.io;
import java.io.*;
import java.util.*;
import java.util.zip.*;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.gui.*;
/**
*
* @author Henrik Lynggaard
* @version
*/
public class PartialAccess implements MozInstallAccess {
Object[] subcomponents;
String fileName;
MozInstall install;
/** Creates new PartialAccess */
public PartialAccess(String fn,MozInstall i)
{
fileName=fn;
install =i;
subcomponents = null;
}
public PartialAccess(String fn,MozInstall i,Object[] sc)
{
fileName=fn;
install =i;
subcomponents = sc;
}
public void load()
{
MainWindow vindue = MainWindow.getDefaultInstance();
Properties prop;
FileInputStream fis;
ZipInputStream zis;
ZipEntry ze;
int componentMax;
int subcomponentMax;
int fileMax;
int phraseMax;
int translationMax;
String componentPrefix;
String subcomponentPrefix;
String filePrefix;
String phrasePrefix;
String translationPrefix;
int qa_status;
String qa_comment;
String loc_name;
String text;
MozComponent currentComponent;
MozComponent currentSubcomponent;
MozFile currentFile;
Phrase currentPhrase;
Translation currentTranslation;
try
{
vindue.setStatus("Loading file");
prop = new Properties();
fis = new FileInputStream(fileName);
zis = new ZipInputStream(fis);
ze = zis.getNextEntry();
prop.load(zis);
zis.closeEntry();
zis.close();
subcomponentMax =Integer.parseInt(prop.getProperty("subcomponent.count"));
for (int subcomponentCount=0;subcomponentCount<subcomponentMax;subcomponentCount++)
{
vindue.setStatus("Parsing subcomponent " + (subcomponentCount+1) + " of " + subcomponentMax); // set the status
subcomponentPrefix = ""+ subcomponentCount + ".";
currentComponent = (MozComponent) install.getChildByName(prop.getProperty(subcomponentPrefix + "parent"));
if (currentComponent!=null)
{
currentSubcomponent = (MozComponent) currentComponent.getChildByName(prop.getProperty(subcomponentPrefix + "name"));
if (currentSubcomponent!=null)
{
fileMax = Integer.parseInt(prop.getProperty(subcomponentPrefix + "count"));
for (int fileCount=0;fileCount<fileMax;fileCount++)
{
filePrefix = subcomponentPrefix + fileCount + ".";
currentFile = (MozFile) currentSubcomponent.getChildByName(prop.getProperty(filePrefix + "name"));
if (currentFile!=null)
{
phraseMax = Integer.parseInt(prop.getProperty(filePrefix + "count"));
for (int phraseCount=0;phraseCount<phraseMax;phraseCount++)
{
phrasePrefix = filePrefix + phraseCount + ".";
currentPhrase = (Phrase) currentFile.getChildByName(prop.getProperty(phrasePrefix + "key"));
if (currentPhrase!=null)
{
translationMax = Integer.parseInt(prop.getProperty(phrasePrefix + "count"));
for (int translationCount=0;translationCount<translationMax;translationCount++)
{
translationPrefix = phrasePrefix + translationCount + ".";
qa_status = Integer.parseInt(prop.getProperty(translationPrefix + "status"));
qa_comment = prop.getProperty(translationPrefix + "comment");
loc_name = prop.getProperty(translationPrefix + "name");
text = prop.getProperty(translationPrefix + "text");
currentTranslation = (Translation) currentPhrase.getChildByName(loc_name);
if (currentTranslation==null)
{
currentTranslation= new Translation(loc_name,currentPhrase,text,qa_status,qa_comment);
currentPhrase.addChild(currentTranslation);
}
else
{
currentTranslation.setStatus(qa_status);
currentTranslation.setComment(qa_comment);
currentTranslation.setText(text);
}
}
}
}
}
}
}
}
}
}
catch (Exception e)
{
Log.write("Exception " + e);
Log.write("Error importing glossary");
}
MainWindow.getDefaultInstance().setStatus("Ready");
}
public void save()
{
MainWindow vindue = MainWindow.getDefaultInstance();
Properties prop = new Properties();
MozComponent currentComponent;
MozComponent currentSubcomponent;
Iterator fileIterator;
Iterator phraseIterator;
Iterator translationIterator;
MozFile currentFile;
Phrase currentPhrase;
Translation currentTranslation;
int fileCounter;
int phraseCounter;
int translationCounter;
String subPrefix;
String filePrefix;
String phrasePrefix;
String translationPrefix;
FileOutputStream fos;
ZipOutputStream zos;
ZipEntry ze;
int subcomponentMax =subcomponents.length;
for (int subCount=0;subCount<subcomponentMax;subCount++)
{
vindue.setStatus("Parsing subcomponent " + (subCount+1) + " of " + subcomponentMax); // set the status
subPrefix = "" + subCount +".";
currentSubcomponent = (MozComponent) subcomponents[subCount];
currentComponent = (MozComponent) currentSubcomponent.getParent();
prop.setProperty(subPrefix + "name",currentSubcomponent.getName());
prop.setProperty(subPrefix + "parent", currentComponent.getName());
fileIterator = currentSubcomponent.getChildIterator();
fileCounter=0;
while (fileIterator.hasNext())
{
filePrefix = subPrefix + fileCounter + ".";
fileCounter++;
currentFile = (MozFile) fileIterator.next();
prop.setProperty(filePrefix + "name", currentFile.getName());
phraseIterator = currentFile.getChildIterator();
phraseCounter=0;
while (phraseIterator.hasNext())
{
phrasePrefix = filePrefix + phraseCounter + ".";
phraseCounter++;
currentPhrase = (Phrase) phraseIterator.next();
prop.setProperty(phrasePrefix + "key",currentPhrase.getName());
translationIterator = currentPhrase.getChildIterator();
translationCounter=0;
while (translationIterator.hasNext())
{
translationPrefix = phrasePrefix + translationCounter + ".";
translationCounter++;
currentTranslation = (Translation) translationIterator.next();
prop.setProperty(translationPrefix + "name", currentTranslation.getName());
prop.setProperty(translationPrefix + "comment", currentTranslation.getComment());
prop.setProperty(translationPrefix + "status", ""+currentTranslation.getStatus());
prop.setProperty(translationPrefix + "text", currentTranslation.getText());
}
prop.setProperty(phrasePrefix + "count",""+translationCounter);
}
prop.setProperty(filePrefix + "count",""+phraseCounter);
}
prop.setProperty(subPrefix + "count" , "" +fileCounter);
}
prop.setProperty("subcomponent.count",""+subcomponentMax);
try
{
vindue.setStatus("Saving file");
fos = new FileOutputStream(fileName);
zos = new ZipOutputStream(fos);
ze = new ZipEntry("glossary.txt");
zos.putNextEntry(ze);
prop.store(zos,"Partial glossary file for MozillaTranslator");
zos.closeEntry();
zos.close();
}
catch(Exception e)
{
Log.write("error writeing partial glossary file");
}
vindue.setStatus("Ready");
}
}

View File

@ -0,0 +1,97 @@
/*
* 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.*;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.kernel.*;
/** This class reads *.properties files from the mozilla chrome
* @author Henrik Lynggaard Hansen
* @version 3.0
*/
public class PropertiesReader extends MozFileReader {
public PropertiesReader(MozFile f,InputStream i)
{
super(f,i);
}
public void readFile(String localeName) throws IOException
{
Properties prop;
Enumeration enum;
String key,text;
Phrase currentPhrase;
Translation currentTranslation;
prop = new Properties();
prop.load(is);
is.close();
enum = prop.propertyNames();
while (enum.hasMoreElements())
{
key = (String) enum.nextElement();
text = prop.getProperty(key);
currentPhrase = (Phrase) fil.getChildByName(key);
if (localeName.equalsIgnoreCase("en-us"))
{
if (currentPhrase==null )
{
currentPhrase = new Phrase(key,fil,text,"",false);
fil.addChild(currentPhrase);
}
else
{
currentPhrase.setText(text);
}
currentPhrase.setMarked(true);
}
else
{
if (currentPhrase!=null)
{
currentTranslation = (Translation) currentPhrase.getChildByName(localeName);
if (currentTranslation==null)
{
currentTranslation = new Translation(localeName,currentPhrase,text);
currentPhrase.addChild(currentTranslation);
}
else
{
currentTranslation.setText(text);
}
}
}
}
}
}

View File

@ -0,0 +1,82 @@
/*
* 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.*;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.kernel.*;
/**
*
* @author Henrik Lynggaard
* @version 4.1
*/
public class PropertiesWriter extends MozFileWriter
{
private static String header ="Translated with MozillaTranslator " + Settings.getString("System.Version","(unknown version)") + " ";
public PropertiesWriter(MozFile f,OutputStream o)
{
super(f,o);
}
public void writeFile(String localeName) throws IOException
{
Properties prop = new Properties();
Iterator phraseIterator;
Phrase currentPhrase;
Translation currentTranslation;
String key,text;
phraseIterator = fil.getChildIterator();
while (phraseIterator.hasNext())
{
currentPhrase = (Phrase) phraseIterator.next();
key = currentPhrase.getName();
currentTranslation = (Translation) currentPhrase.getChildByName(localeName);
if (currentTranslation == null || localeName.equals("en-us"))
{
text = currentPhrase.getText();
}
else
{
text = currentTranslation.getText();
}
prop.setProperty(key,text);
}
prop.store(os,header);
os.close();
}
}

View File

@ -0,0 +1,76 @@
/*
* SplitInputStream.java
*
* Created on 3. september 2000, 13:25
*/
package org.mozilla.translator.io;
import java.io.*;
/**
*
* @author Henrik Lynggaard
* @version
*/
public class SplitInputStream extends InputStream {
InputStream currentStream;
/** Creates new SplitInputSt ream */
public SplitInputStream(InputStream is)
{
super();
currentStream = is;
}
public int available() throws IOException
{
return currentStream.available();
}
public void close() throws IOException
{
// does nothing, and shoudl do nothing;
}
public void mark(int readlimit)
{
currentStream.mark(readlimit);
}
public boolean markSupported()
{
return currentStream.markSupported();
}
public int read() throws IOException
{
return currentStream.read();
}
public int read(byte[] b) throws IOException
{
return currentStream.read(b);
}
public int read(byte[] b, int off, int len) throws IOException
{
return currentStream.read(b,off,len);
}
public void reset() throws IOException
{
currentStream.reset();
}
public long skip(long n) throws IOException
{
return currentStream.skip(n);
}
}

View File

@ -0,0 +1,40 @@
/*
* 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.kernel;
/**
*
* @author Henrik Lynggaard
* @version 4.1
*/
public class BatchControl extends java.lang.Object {
public static void runBatch(String[] commands)
{
for (int a=0;a<commands.length;a++)
{
Log.write("" + a + ". command :" + commands[a]);
}
}
}

View File

@ -0,0 +1,86 @@
/*
* 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.kernel;
import java.util.*;
/** This class contains the default Settings for MozillaTranslator.
*
* @author Henrik Lynggaard Hansen
* @version 4.15
*/
public class DefaultSettings extends Object {
private Properties prop;
/** Creates new DefaultSettings */
public DefaultSettings()
{
prop = new Properties();
// system settings
prop.setProperty("System.Version","4.15");
prop.setProperty("System.Groupware","false"); // to be used later
prop.setProperty("System.Glossaryfile","glossary.zip");
prop.setProperty("System.Filterfile","Filters.properties");
//log settings
prop.setProperty("Log.toScreen","true");
prop.setProperty("Log.toFile","true");
prop.setProperty("Log.fileName","MozillaTranslator.errors");
// translation related settings
prop.setProperty("Locale.dtd_licence","mpl_dtd.txt");
prop.setProperty("Locale.properties_licence","mpl_properties.txt");
// saved properties, not really needed here, it it just documentation
// saved.localeName
// saved.install
// saved.author
// saved.displayName
// saved.previewURL
// saved.version
// saved.fileName.xpi
// saved.dirName.package
// saved.fileName.partial.import
// saved.fileName.partial.export
// saved.search.text
// saved.search.rule
// saved.search.field
// saved.column.<XXX>
// saved.subs.<XXX> (to be done later)
}
/** Returns the default properties.
* @return The Default properties
*/
public Properties getDefaults()
{
return prop;
}
}

View File

@ -0,0 +1,77 @@
/*
* 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.kernel;
import java.io.*;
/** This class is used to log errors
* @author Henrik Lynggaard Hansen
* @version 4.01
*/
public class Log extends Object {
private static boolean toScr;
private static boolean toFile;
private static String fileName;
/** This inits the log and readies it for use
*
*/
public static void init()
{
toScr = Settings.getBoolean("Log.toScreen",false);
toFile = Settings.getBoolean("Log.toFile",false);
fileName = Settings.getString("Log.fileName","");
}
/** This writes a piece of text to the log
* @param text The text to be logged
*/
public static void write(String text)
{
FileWriter fw;
PrintWriter pw;
if (toScr)
{
System.out.println(text);
}
if (toFile)
{
try
{
fw = new FileWriter(fileName,true);
pw = new PrintWriter(fw);
pw.println(text);
pw.close();
}
catch (Exception e)
{
System.out.println("Error writing to log file");
System.out.println("The message was:\n");
}
}
}
}

View File

@ -0,0 +1,61 @@
/*
* 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.kernel;
import org.mozilla.translator.gui.*;
import org.mozilla.translator.gui.models.*;
import org.mozilla.translator.datamodel.*;
/** This class is the main class which is run by the user
* @author Henrik Lynggaard Hansen
* @version 4.01
*/
public class Program extends Object {
/** The method that is run on startup
* @param args the command line arguments
*/
public static void main (String args[])
{
Settings.init("MozillaTranslator.properties");
Log.init();
MainWindow.init();
if (args.length==0)
{
MainWindow.getDefaultInstance().setVisible(true);
}
ComplexColumn.init();
Glossary.init();
if (args.length>0)
{
BatchControl.runBatch(args);
}
}
}

View File

@ -0,0 +1,127 @@
/*
* 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.kernel;
import java.io.*;
import java.util.*;
/** This class wraps the java.util.Properties, with handy mehtods
* and a singelton pattern
* @author Henrik Lynggaard Hansen
* @version 4.0
*/
public class Settings extends Object {
private static Properties prop;
private static String fileName;
/** This method will init the settings with default values, and then load in the
* user settings from the file.
* @param fn The filename for the properties file
*/
public static void init(String fn)
{
FileInputStream fis; // used to load the propeties from file
DefaultSettings def; // the set of system defaults
fileName=fn;
def = new DefaultSettings();
prop = new Properties(def.getDefaults());
try
{
fis = new FileInputStream(fileName);
prop.load(fis);
fis.close();
}
catch (Exception e)
{
// Silently ignore that we have no properties
}
}
/** This set a settings to a string value
* @param key The key of the property
* @param value The new value of the property
*/
public static void setString(String key,String value)
{
prop.setProperty(key,value);
}
public static void setBoolean(String key,boolean value)
{
String strValue = String.valueOf(value);
prop.setProperty(key,strValue);
}
public static void setInteger(String key,int value)
{
String strValue = Integer.toString(value);
prop.setProperty(key,strValue);
}
public static String getString(String key,String defValue)
{
return prop.getProperty(key, defValue);
}
public static boolean getBoolean(String key,boolean defValue)
{
boolean result;
String tempResult;
tempResult = prop.getProperty(key, String.valueOf(defValue));
result = Boolean.valueOf(tempResult).booleanValue();
return result;
}
public static int getInteger(String key, int defValue)
{
String tempResult;
tempResult = prop.getProperty(key,String.valueOf(defValue));
return Integer.parseInt(tempResult);
}
public static void save()
{
FileOutputStream fos; // used to save the properties
try
{
fos = new FileOutputStream(fileName);
prop.store(fos,"Settings for mozillaTranslator");
fos.close();
}
catch (Exception e)
{
Log.write("Error saving property file");
}
}
}

View File

@ -0,0 +1,48 @@
/*
* 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.kernel;
import java.awt.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version 4.0
*/
public class Utils extends Object {
public static void placeFrameAtCenter(Component frame)
{
int x;
int y;
Dimension scr = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frm = frame.getSize();
x = (int) ( (scr.getWidth()/2) - (frm.getWidth()/2) );
y = (int) ( (scr.getHeight()/2) - (frm.getHeight()/2) );
frame.setLocation(x,y);
}
}

View File

@ -0,0 +1,23 @@
/*
* 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)
*
*/

View File

@ -0,0 +1,57 @@
/*
* 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.*;
/**
*
* @author Henrik
* @version
*/
public class ExportPartialGlossaryRunner extends Thread {
private MozInstall install;
private Object[] subs;
private String fileName;
/** Creates new ExportPartialGlossaryRunner */
public ExportPartialGlossaryRunner(MozInstall i,Object[] s,String fn)
{
install =i;
subs = s;
fileName = fn;
}
public void run()
{
PartialAccess pa = new PartialAccess(fileName,install,subs);
pa.save();
}
}

View File

@ -0,0 +1,193 @@
/*
* 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.gui.*;
import org.mozilla.translator.kernel.*;
/**
*
* @author Henrik Lynggaard Hansen
* @version 4.0
*/
public class ImportOldGlossaryRunner extends Thread {
private MozInstall install;
private String glosFile;
/** Creates new ImportOldGlossary */
public ImportOldGlossaryRunner(MozInstall i,String glos)
{
install =i;
glosFile = glos;
}
public void run()
{
Properties prop;
FileInputStream fis;
ZipInputStream zis;
ZipEntry ze;
Iterator componentIterator;
Iterator subcomponentIterator;
Iterator fileIterator;
MozComponent currentComponent;
MozComponent currentSubcomponent;
MozFile currentFile;
Phrase currentPhrase;
Translation currentTranslation;
MozComponent allFiles;
int componentCount;
int fileCount;
String compPrefix;
String filePrefix;
String fileName;
String phrasePrefix;
String localePrefix;
String key;
int phraseCount;
String locales,singleLocale;
int qa;
StringTokenizer localeTokenizer;
String translated,comment;
MainWindow vindue = MainWindow.getDefaultInstance();
prop = new Properties();
allFiles = new MozComponent("temp",null);
// build a all file list of install
vindue.setStatus("Building list of all files");
try
{
componentIterator = install.getChildIterator();
while (componentIterator.hasNext())
{
currentComponent = (MozComponent) componentIterator.next();
subcomponentIterator = currentComponent.getChildIterator();
while (subcomponentIterator.hasNext())
{
currentSubcomponent = (MozComponent) subcomponentIterator.next();
fileIterator = currentSubcomponent.getChildIterator();
while (fileIterator.hasNext())
{
allFiles.addChild((MozFile) fileIterator.next());
}
}
}
// load old glossary in properties
vindue.setStatus("Loading old glossary");
fis = new FileInputStream(glosFile);
zis = new ZipInputStream(fis);
ze = zis.getNextEntry();
prop.load(zis);
zis.closeEntry();
zis.close();
componentCount = Integer.parseInt(prop.getProperty("componentCount"));
// match files in old with the all file List
for (int c=0;c<componentCount;c++)
{
compPrefix = "" + c + ".";
fileCount = Integer.parseInt(prop.getProperty(compPrefix+ "fileCount"));
for (int f=0;f<fileCount;f++)
{
filePrefix = compPrefix + f + ".";
fileName = prop.getProperty(filePrefix + "name");
currentFile = (MozFile) allFiles.getChildByName(fileName);
if (currentFile!=null)
{
vindue.setStatus("Migrateing file : " + currentFile.getName());
// match any keys in the matched files
phraseCount = Integer.parseInt(prop.getProperty(filePrefix + "phraseCount"));
for (int p=0;p<phraseCount;p++)
{
phrasePrefix = filePrefix + p + ".";
key = prop.getProperty(phrasePrefix + "key");
currentPhrase = (Phrase) currentFile.getChildByName(key);
if (currentPhrase!=null)
{
// match or add any locales
locales = prop.getProperty(phrasePrefix + "locales", "NONE");
if (!locales.equals("NONE"))
{
localeTokenizer = new StringTokenizer(locales,",",false);
while (localeTokenizer.hasMoreTokens())
{
singleLocale = localeTokenizer.nextToken();
localePrefix = phrasePrefix + singleLocale +".";
translated = prop.getProperty(localePrefix +"text");
qa = Integer.parseInt(prop.getProperty(localePrefix +"qa",""+Translation.QA_NOTSEEN));
comment = prop.getProperty(localePrefix +"comment","");
currentTranslation = (Translation) currentPhrase.getChildByName(singleLocale);
if ((currentTranslation==null) && (!translated.equals("")))
{
currentTranslation = new Translation(singleLocale,currentPhrase,translated,qa,comment);
currentPhrase.addChild(currentTranslation);
}
}
}
}
}
}
}
}
}
catch (Exception e)
{
Log.write("Error importing old glossary");
Log.write("Exception " + e);
}
MainWindow.getDefaultInstance().setStatus("Ready");
}
}

View File

@ -0,0 +1,56 @@
/*
* 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 ImportPartialGlossaryRunner extends Thread {
MozInstall install;
String fileName;
/** Creates new ImportPartialGlossary */
public ImportPartialGlossaryRunner(MozInstall i,String fn)
{
install=i;
fileName=fn;
}
public void run()
{
PartialAccess pa = new PartialAccess(fileName,install);
pa.load();
}
}

View File

@ -0,0 +1,57 @@
/*
* 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 org.mozilla.translator.io.*;
/**
*
* @author Henrik
* @version 4.0
*/
public class LoadGlossaryRunner extends Thread {
/** Creates new LoadGlossaryRunner */
public LoadGlossaryRunner()
{
//empty
}
public void run()
{
GlossaryAccess ga = new GlossaryAccess();
ga.load();
}
}

View File

@ -0,0 +1,45 @@
/*
* 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 org.mozilla.translator.io.*;
/**
*
* @author Henrik
* @version
*/
public class SaveGlossaryRunner extends Thread {
/** Creates new SaveGlossaryRunner */
public SaveGlossaryRunner()
{
// empty
}
public void run()
{
GlossaryAccess ga = new GlossaryAccess();
ga.save();
}
}

View File

@ -0,0 +1,455 @@
/*
* 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.jar.*;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.io.*;
import org.mozilla.translator.gui.*;
import org.mozilla.translator.gui.dialog.*;
/**
*
* @author Henrik
* @version 4.0
*/
public class UpdateInstallRunner extends Thread
{
private MozInstall install;
/** Creates new UpdateInstallRunner */
public UpdateInstallRunner(MozInstall i)
{
this.install=i;
}
public void run()
{
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;
MainWindow vindue = MainWindow.getDefaultInstance();
baseName = install.getPath();
baseFile = new File(baseName);
if (baseFile.isDirectory())
{
updateFromDirectory();
}
else
{
try
{
updateFromJar();
}
catch (Exception e) { Log.write("Exception in updateFromJar() " + e); }
}
vindue.setStatus("Removing dead phrases");
componentIterator = install.getChildIterator();
while (componentIterator.hasNext())
{
currentComponent = (MozComponent) componentIterator.next();
if (currentComponent.isMarked())
{
subComponentIterator = currentComponent.getChildIterator();
while (subComponentIterator.hasNext())
{
currentSubComponent = (MozComponent) subComponentIterator.next();
if (currentSubComponent.isMarked())
{
fileIterator = currentSubComponent.getChildIterator();
while (fileIterator.hasNext())
{
currentFile = (MozFile) fileIterator.next();
if (currentFile.isMarked())
{
phraseIterator = currentFile.getChildIterator();
while (phraseIterator.hasNext())
{
currentPhrase = (Phrase) phraseIterator.next();
if (currentPhrase.isMarked())
{
currentPhrase.setMarked(false);
}
else
{
phraseIterator.remove();
}
}
currentFile.setMarked(false);
}
else
{
fileIterator.remove();
}
}
currentSubComponent.setMarked(false);
}
else
{
subComponentIterator.remove();
}
}
currentComponent.setMarked(false);
}
else
{
componentIterator.remove();
}
}
MainWindow.getDefaultInstance().setStatus("Ready");
//ShowWhatDialog swd = new ShowWhatDialog();
// (swd.visDialog())
//
//mplexTableWindow ctw = new ComplexTableWindow("Changed Strings", collectedList,swd.getSelectedColumns(),swd.getSelectedLocale());
//
}
private void updateFromDirectory()
{
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;
MainWindow vindue = MainWindow.getDefaultInstance();
baseName = install.getPath();
baseFile = new File(baseName);
int filesDone=0;
components = baseFile.list();
for (int i=0;i<components.length;i++)
{
currentComponentFile = new File(baseName + File.separator + components[i],"locale");
if (currentComponentFile.isDirectory())
{
currentComponent = (MozComponent) install.getChildByName(components[i]);
if (currentComponent==null)
{
currentComponent = new MozComponent(components[i],install);
install.addChild(currentComponent);
}
currentComponent.setMarked(true);
subcomponents = currentComponentFile.list();
for (int j=0;j<subcomponents.length;j++)
{
currentSubComponentFile = new File(currentComponentFile,subcomponents[j]);
if (currentSubComponentFile.isDirectory())
{
currentSubComponent = (MozComponent) currentComponent.getChildByName(subcomponents[j]);
if (currentSubComponent==null)
{
currentSubComponent = new MozComponent(subcomponents[j],currentComponent);
currentComponent.addChild(currentSubComponent);
}
currentSubComponent.setMarked(true);
files = currentSubComponentFile.list();
for (int k=0;k<files.length;k++)
{
currentFileFile = new File(currentSubComponentFile,files[k]);
currentFile = (MozFile) currentSubComponent.getChildByName(files[k]);
if (currentFile==null)
{
currentFile = new MozFile(files[k],currentSubComponent);
currentSubComponent.addChild(currentFile);
}
currentFile.setMarked(true);
vindue.setStatus("Files done : " + filesDone + ", currently reading : " +currentFile);
readFile(currentFileFile,currentFile);
filesDone++;
}
}
else
{
currentSubComponent = (MozComponent) currentComponent.getChildByName("MT_default");
if (currentSubComponent==null)
{
currentSubComponent = new MozComponent("MT_default",currentComponent);
currentComponent.addChild(currentSubComponent);
}
currentSubComponent.setMarked(true);
currentFile = (MozFile) currentSubComponent.getChildByName(subcomponents[j]);
if (currentFile==null)
{
currentFile = new MozFile(subcomponents[j],currentSubComponent);
currentSubComponent.addChild(currentFile);
}
currentFile.setMarked(true);
vindue.setStatus("Files done : " + filesDone + ", currently reading : " +currentFile);
readFile(currentSubComponentFile,currentFile);
filesDone++;
}
}
}
}
}
private void updateFromJar() throws FileNotFoundException,IOException
{
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;
MainWindow vindue = MainWindow.getDefaultInstance();
baseName = install.getPath();
FileInputStream fis = new FileInputStream(baseName);
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)
{
currentComponent = new MozComponent(componentToken,install);
install.addChild(currentComponent);
}
currentComponent.setMarked(true);
currentSubComponent = (MozComponent) currentComponent.getChildByName(subcomponentToken);
if (currentSubComponent==null)
{
currentSubComponent = new MozComponent(subcomponentToken,currentComponent);
currentComponent.addChild(currentSubComponent);
}
currentSubComponent.setMarked(true);
currentFile = (MozFile) currentSubComponent.getChildByName(fileToken);
if (currentFile==null)
{
currentFile = new MozFile(fileToken,currentSubComponent);
currentSubComponent.addChild(currentFile);
}
currentFile.setMarked(true);
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;
}
}
}
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("en-US");
}
else
{
Phrase tempPhrase = new Phrase("MT_unsupported",m_fil,"MT_unsupported","MT_unsupported",false);
m_fil.addChild(tempPhrase);
}
}
catch (Exception e)
{
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;
}
}

View File

@ -0,0 +1,210 @@
/*
* 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.util.*;
import java.io.*;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.io.*;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.gui.*;
/**
*
* @author Henrik
* @version
*/
public class WritePackageRunner extends Thread {
private MozInstall install;
private String fileName;
private String localeName;
private String author,display,preview;
/** Creates new WritePackageRunner */
public WritePackageRunner(MozInstall i,String fn,String ln,String a,String d,String p)
{
install=i;
fileName=fn;
localeName=ln;
author =a;
display=d;
preview=p;
}
public void run()
{
File baseDir;
File componentDir;
File subcomponentDir;
File localeDir;
File fileFile;
Iterator componentIterator;
Iterator subcomponentIterator;
Iterator fileIterator;
MozComponent currentComponent;
MozComponent currentSubComponent;
MozFile currentFile;
int filesDone=0;
MainWindow vindue = MainWindow.getDefaultInstance();
baseDir = new File(fileName);
makeDir(baseDir);
componentIterator = install.getChildIterator();
while (componentIterator.hasNext())
{
currentComponent = (MozComponent) componentIterator.next();
componentDir = new File(baseDir,currentComponent.getName());
makeDir(componentDir);
subcomponentIterator = currentComponent.getChildIterator();
while (subcomponentIterator.hasNext())
{
currentSubComponent = (MozComponent) subcomponentIterator.next();
localeDir = new File(componentDir,"locale");
makeDir(localeDir);
if (currentSubComponent.getName().equals("MT_default"))
{
subcomponentDir = localeDir;
}
else
{
subcomponentDir = new File(localeDir,currentSubComponent.getName());
makeDir(subcomponentDir);
}
fileIterator = currentSubComponent.getChildIterator();
while (fileIterator.hasNext())
{
currentFile =(MozFile) fileIterator.next();
vindue.setStatus("Files done: " + filesDone + ", currently writeing: " + currentFile);
writeFile(subcomponentDir,currentFile);
filesDone++;
}
}
}
vindue.setStatus("Writeing manifest file");
writeManifest(baseDir);
vindue.setStatus("Ready");
}
private void makeDir(File fil)
{
if (!fil.exists())
{
fil.mkdir();
}
}
private void writeFile(File dir,MozFile fil)
{
MozFileWriter writer;
FileOutputStream fos;
Iterator phraseIterator;
Phrase currentPhrase;
Translation currentTranslation;
String key;
String text;
try
{
fos = new FileOutputStream(dir + File.separator + fil);
writer = MozIo.getFileWriter(fil,fos);
writer.writeFile(localeName);
}
catch (Exception e)
{
Log.write("Error writing file: " + fil);
Log.write("Exception : "+ e);
}
}
private void writeManifest(File dir)
{
Iterator componentIterator;
MozComponent currentComponent;
try
{
File fil = new File(dir,"manifest.rdf");
FileWriter fw= new FileWriter(fil);
PrintWriter pw = new PrintWriter(fw);
pw.println("<?xml version=\"1.0\"?>");
pw.println("<RDF:RDF xmlns:RDF=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"");
pw.println(" xmlns:chrome=\"http://www.mozilla.org/rdf/chrome#\">");
pw.println();
pw.println(" <RDF:Seq about=\"urn:mozilla:locale:root\">");
pw.println(" <RDF:li resource=\"urn:mozilla:locale:" + localeName + "\"/>");
pw.println(" </RDF:Seq>");
pw.println();
pw.println(" <RDF:Description about=\"urn:mozilla:locale:" + localeName +"\"");
pw.println(" chrome:displayName=\"" + display + "\"");
pw.println(" chrome:author=\"" + author + "\"");
pw.println(" chrome:name=\"" + localeName + "\"");
pw.println(" chrome:previewURL=\"" + preview + "\">");
pw.println();
pw.println(" <chrome:packages>");
pw.println(" <RDF:Seq about=\"urn:mozilla:locale:" + localeName+ ":packages\">");
componentIterator = install.getChildIterator();
while (componentIterator.hasNext())
{
currentComponent = (MozComponent) componentIterator.next();
pw.println(" <RDF:li resource=\"urn:mozilla:locale:" + localeName + ":" + currentComponent.getName() + "\"/>");
}
pw.println(" </RDF:Seq>");
pw.println(" </chrome:packages>");
pw.println(" </RDF:Description>");
pw.println("</RDF:RDF>");
pw.close();
}
catch (Exception e)
{
Log.write("Error writing manifest file");
}
}
}

View File

@ -0,0 +1,309 @@
/*
* 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.util.*;
import java.util.zip.*;
import java.io.*;
import org.mozilla.translator.datamodel.*;
import org.mozilla.translator.io.*;
import org.mozilla.translator.kernel.*;
import org.mozilla.translator.gui.*;
/**
*
* @author Henrik
* @version 4.1
*/
public class WriteXpiRunner extends Thread {
private MozInstall install;
private String fileName;
private String localeName;
private String author,display,preview;
private String version;
private File zipFile;
private FileOutputStream fos;
private ZipOutputStream zos;
private BufferedOutputStream bos;
private String entryName;
/** Creates new WritePackageRunner */
public WriteXpiRunner(MozInstall i,String fn,String ln,String a,String d,String p,String v)
{
install=i;
fileName=fn;
localeName=ln;
author =a;
display=d;
preview=p;
version=v;
}
public void run()
{
MainWindow vindue = MainWindow.getDefaultInstance();
String componentPrefix;
String subcomponentPrefix;
String filePrefix;
Iterator componentIterator;
Iterator subcomponentIterator;
Iterator fileIterator;
MozComponent currentComponent;
MozComponent currentSubComponent;
MozFile currentFile;
int filesDone=0;
try
{
zipFile = new File(fileName);
fos = new FileOutputStream(zipFile);
zos = new ZipOutputStream(fos);
bos = new BufferedOutputStream(zos);
componentIterator = install.getChildIterator();
while (componentIterator.hasNext())
{
currentComponent = (MozComponent) componentIterator.next();
componentPrefix = localeName + File.separator + currentComponent.getName();
subcomponentIterator = currentComponent.getChildIterator();
while (subcomponentIterator.hasNext())
{
currentSubComponent = (MozComponent) subcomponentIterator.next();
subcomponentPrefix = componentPrefix + File.separator + "locale";
if (!currentSubComponent.getName().equals("MT_default"))
{
subcomponentPrefix = subcomponentPrefix + File.separator + currentSubComponent.getName();
}
fileIterator = currentSubComponent.getChildIterator();
while (fileIterator.hasNext())
{
currentFile =(MozFile) fileIterator.next();
entryName = subcomponentPrefix + File.separator + currentFile.getName();
vindue.setStatus("files done: " + filesDone + ", currently packing: " + currentFile);
writeFile(currentFile);
filesDone++;
}
}
}
writeManifest();
writeInstallScript();
bos.close();
}
catch (Exception e)
{
Log.write("Error writing xpi file");
Log.write("Exception: " +e);
}
MainWindow.getDefaultInstance().setStatus("Ready");
}
private void writeFile(MozFile fil) throws IOException
{
File temp;
MozFileWriter writer;
FileOutputStream fos;
MozInstall install;
MozComponent comp,subcomp;
String origFilename;
temp = File.createTempFile("MT_",null);
fos = new FileOutputStream(temp);
writer = MozIo.getFileWriter(fil,fos);
if (writer!=null)
{
writer.writeFile(localeName);
copyFile(temp,entryName);
temp.delete();
}
else
{
subcomp = (MozComponent) fil.getParent();
comp = (MozComponent) subcomp.getParent();
install = (MozInstall) comp.getParent();
origFilename = install.getPath() + File.separator + comp.getName();
origFilename = origFilename + File.separator + "locale";
if (!subcomp.getName().equals("MT_default"))
{
origFilename = origFilename + File.separator + subcomp.getName();
}
origFilename = origFilename + File.separator + fil.getName();
File orig = new File(origFilename);
copyFile(orig,entryName);
}
}
private void writeManifest()
{
Iterator componentIterator;
MozComponent currentComponent;
try
{
File fil = File.createTempFile("MT_",null);
FileWriter fw= new FileWriter(fil);
PrintWriter pw = new PrintWriter(fw);
pw.println("<?xml version=\"1.0\"?>");
pw.println("<RDF:RDF xmlns:RDF=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"");
pw.println(" xmlns:chrome=\"http://www.mozilla.org/rdf/chrome#\">");
pw.println();
pw.println(" <RDF:Seq about=\"urn:mozilla:locale:root\">");
pw.println(" <RDF:li resource=\"urn:mozilla:locale:" + localeName + "\"/>");
pw.println(" </RDF:Seq>");
pw.println();
pw.println(" <RDF:Description about=\"urn:mozilla:locale:" + localeName +"\"");
pw.println(" chrome:displayName=\"" + display + "\"");
pw.println(" chrome:author=\"" + author + "\"");
pw.println(" chrome:name=\"" + localeName + "\"");
pw.println(" chrome:previewURL=\"" + preview + "\">");
pw.println();
pw.println(" <chrome:packages>");
pw.println(" <RDF:Seq about=\"urn:mozilla:locale:" + localeName+ ":packages\">");
componentIterator = install.getChildIterator();
while (componentIterator.hasNext())
{
currentComponent = (MozComponent) componentIterator.next();
pw.println(" <RDF:li resource=\"urn:mozilla:locale:" + localeName + ":" + currentComponent.getName() + "\"/>");
}
pw.println(" </RDF:Seq>");
pw.println(" </chrome:packages>");
pw.println(" </RDF:Description>");
pw.println("</RDF:RDF>");
pw.close();
copyFile(fil,""+localeName + File.separator + "manifest.rdf");
fil.delete();
}
catch (Exception e)
{
Log.write("Error writing manifest file");
}
}
private void writeInstallScript()
{
Iterator componentIterator;
MozComponent currentComponent;
try
{
File fil = File.createTempFile("MT_",null);
FileWriter fw= new FileWriter(fil);
PrintWriter pw = new PrintWriter(fw);
// the text in the file
pw.println("initInstall(\""+ display + "\", \"locales/" + author + "/" + localeName + "\", \"" + version + "\");");
pw.println("var dest = getFolder(\"Chrome\", \"locales/" + localeName +"\");");
pw.println("var err = addDirectory(\"\", \"" + localeName + "\", dest, \"\");");
pw.println();
pw.println("if (!err)");
pw.println("{");
pw.println(" err = registerChrome(LOCALE, dest);");
pw.println(" if (err == SUCCESS)");
pw.println(" {");
pw.println(" performInstall();");
pw.println(" }");
pw.println(" else");
pw.println(" {");
pw.println(" cancelInstall(err);");
pw.println(" }");
pw.println("}");
// end of text
pw.close();
copyFile(fil,"install.js");
fil.delete();
}
catch (Exception e)
{
Log.write("Error writing installScript file");
}
}
private void copyFile(File tempFile,String eName) throws IOException
{
ZipEntry ze;
FileInputStream fis;
BufferedInputStream bis;
boolean theEnd;
int trans;
ze = new ZipEntry(eName);
zos.putNextEntry(ze);
fis = new FileInputStream(tempFile);
bis = new BufferedInputStream(fis);
theEnd=false;
while (!theEnd)
{
trans = bis.read();
if (trans==-1)
{
theEnd = true;
}
else
{
bos.write(trans);
}
}
bis.close();
bos.flush();
}
}

View File

View File

@ -0,0 +1,18 @@
WishList / todo:
+ Filters
+ HTML file export
+ Keyboard OK/Cancel
+ Edit mutiple entries at one time
+ SQL database support for storing glossary file
+ SpellChecker
+ remember state on all dialogs
+ support for reading installs inside jar files.
+ *.rdf file support
+ Revamp Settings names for remembering
+ Revamp keyboard navigation
+ Fix bug in install.js
+ Fix Settings.getXXX to accept defaultValues
+ columns shouldn't resize when changeing file in chrome view
+ Command line mode
+ Fix localization note stuff (better scope support)
+ Expert settings