home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Window;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.InputStream;
- import java.util.Enumeration;
- import java.util.Vector;
- import sun.plugin.converter.ResourceHandler;
- import sun.plugin.converter.engine.DefaultSet;
- import sun.plugin.converter.engine.PluginConverter;
- import sun.plugin.converter.gui.ConverterGUI;
- import sun.plugin.converter.util.CommandLine;
- import sun.plugin.converter.util.FlexFilter;
- import sun.plugin.converter.util.NotDirectoryException;
-
- public class HTMLConverter {
- private CommandLine cmdLine;
- private FlexFilter fileFilter = new FlexFilter();
- private PluginConverter converter = null;
- private DefaultSet set = null;
- private File logFile = null;
- private String sourceStr = null;
- private String backupStr = null;
- private String destStr = null;
- private String tempStr = null;
- private String logStr = null;
- private String sep = System.getProperty("file.separator");
- // $FF: synthetic field
- static Class class$HTMLConverter;
-
- public HTMLConverter(String[] var1) {
- this.cmdLine = new CommandLine(var1);
- if (this.cmdLine.justHelp()) {
- this.showHelp();
- System.exit(0);
- }
-
- if (this.cmdLine.doGUI()) {
- this.processWithGUI();
- } else {
- this.processCommandLine();
- }
-
- }
-
- private void processWithGUI() {
- ConverterGUI var1 = new ConverterGUI();
- ((Window)var1).pack();
- var1.setVisible(true);
- }
-
- private void processCommandLine() {
- try {
- this.converter = new PluginConverter(this.cmdLine.isLogFile(), this.cmdLine.showProgress());
- this.converter.setConvertSet(this.set = new DefaultSet());
- this.converter.setCommandLine(true);
- } catch (FileNotFoundException var4) {
- System.out.println(ResourceHandler.getMessage("notemplate_dialog.info0") + PluginConverter.getDefaultTemplateFileName() + ResourceHandler.getMessage("notemplate_dialog.info1"));
- }
-
- try {
- Vector var1 = this.cmdLine.getFileSpecs();
- Enumeration var2 = var1.elements();
-
- while(var2.hasMoreElements()) {
- this.fileFilter.addDescriptor((String)var2.nextElement());
- }
-
- if (this.cmdLine.doSubDirs()) {
- this.fileFilter.setFilesOnly(false);
- this.converter.setRecurse(true);
- }
-
- if (this.cmdLine.showProgress()) {
- this.converter.setShowProgressStdOut(true);
- }
-
- this.setSource();
- this.setDest();
- this.setBack();
- this.setTemp();
- this.setLog();
- Enumeration var3 = this.set.getFilesEnumeration();
- if (this.set.getFileCount() == 0) {
- System.out.println(ResourceHandler.getMessage("plugin_converter.nofiles"));
- System.exit(0);
- } else if (this.cmdLine.justSimulate()) {
- this.simulate(var3);
- } else {
- this.converter.startConversion();
- }
- } catch (IndexOutOfBoundsException var5) {
- this.showHelp();
- System.exit(0);
- }
-
- }
-
- private void showHelp() {
- System.out.println(ResourceHandler.getMessage("plugin_converter.help_message"));
- }
-
- public static boolean checkTrue(String var0) {
- var0 = var0.trim().toUpperCase();
- return var0.equals("TRUE") || var0.equals("T") || var0.equals("YES") || var0.equals("Y");
- }
-
- private void setSource() {
- this.sourceStr = this.cmdLine.getSourceDir();
- if (this.sourceStr != null) {
- try {
- File var1 = new File(this.sourceStr);
- this.set.setSourcePath(var1, this.fileFilter);
- } catch (NotDirectoryException var2) {
- System.out.println(((Throwable)var2).getMessage());
- System.exit(0);
- }
- } else {
- this.set.setFiles(this.fileFilter);
- }
-
- }
-
- private void setDest() {
- this.destStr = this.cmdLine.getDestDir();
- if (this.destStr != null) {
- File var1 = new File(this.destStr);
- this.set.setDestinationPath(var1);
- } else {
- this.set.setDestinationPath(this.set.getDefaultDestPath());
- }
-
- }
-
- private void setBack() {
- this.backupStr = this.cmdLine.getBackupDir();
- if (this.backupStr != null) {
- File var1 = new File(this.backupStr);
- this.set.setBackupPath(var1);
- } else {
- this.set.setBackupPath(this.set.getDefaultBackupPath());
- }
-
- }
-
- private void setTemp() {
- this.tempStr = this.cmdLine.getTemplateDir();
- if (this.tempStr != null) {
- try {
- InputStream var1 = (class$HTMLConverter == null ? (class$HTMLConverter = class$("HTMLConverter")) : class$HTMLConverter).getClassLoader().getResourceAsStream(this.tempStr);
- this.converter.setTemplateFilePath(this.tempStr);
- } catch (FileNotFoundException var2) {
- System.out.println(ResourceHandler.getMessage("nottemplatefile_dialog.info2") + ": " + this.tempStr);
- }
- }
-
- }
-
- private void setLog() {
- this.logStr = this.cmdLine.getLogFile();
- if (this.logStr != null) {
- this.logFile = new File(this.logStr);
- this.converter.setLogFile(this.logFile);
- }
-
- }
-
- private void simulate(Enumeration var1) {
- System.out.println(ResourceHandler.getMessage("plugin_converter.files"));
-
- while(var1.hasMoreElements()) {
- System.out.println(this.set.getSourcePath() + this.sep + (String)var1.nextElement());
- }
-
- System.out.println("\n" + ResourceHandler.getMessage("plugin_converter.backup_path") + ":\t" + this.set.getBackupPath());
- if (this.logFile != null) {
- System.out.println(ResourceHandler.getMessage("plugin_converter.log_path") + ":\t" + (this.cmdLine.getLogFile() == null ? this.converter.getDefaultLogFile().getAbsolutePath() : this.logFile.getAbsolutePath()));
- }
-
- System.out.println("\n" + ResourceHandler.getMessage("plugin_converter.template_file") + ":\t" + this.converter.getTemplateFilePath());
- System.out.println(ResourceHandler.getMessage("plugin_converter.process_subdirs") + ":\t" + this.converter.isRecurse());
- System.out.println(ResourceHandler.getMessage("plugin_converter.show_progress") + ":\t" + this.converter.isShowProgressStdOut());
- System.out.println("");
- }
-
- public static void main(String[] var0) {
- new HTMLConverter(var0);
- }
-
- // $FF: synthetic method
- static Class class$(String var0) {
- try {
- return Class.forName(var0);
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
- }
- }
-