diff --git a/pom.xml b/pom.xml index 4d5a17b..53ab297 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,6 @@ - \ No newline at end of file diff --git a/src/main/java/org/tableau/editor/build/AppMaster.java b/src/main/java/org/tableau/editor/build/AppMaster.java index 10ecd50..c955618 100644 --- a/src/main/java/org/tableau/editor/build/AppMaster.java +++ b/src/main/java/org/tableau/editor/build/AppMaster.java @@ -15,9 +15,9 @@ Tableau Editor Copyright (C) 2018 Rishu Kumar Shrivastava (rishu.shrivastava@g import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; -import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.Properties; @@ -53,14 +53,15 @@ public class AppMaster extends JFrame implements ActionListener { ArrayList filetoprocess = new ArrayList(); String message_file=""; - ImageIcon img = new ImageIcon("src/main/resources/images/Tableau-EditorIcon.png"); + + ImageIcon img = new ImageIcon(this.getClass().getClassLoader().getResource("images/Tableau-EditorIcon.png")); Properties prop; public AppMaster() { try { - FileInputStream fis = new FileInputStream("src/main/resources/config/master_config.properties"); + InputStream fis = this.getClass().getClassLoader().getResourceAsStream("config/master_config.properties"); prop = new Properties(); prop.load(fis); @@ -113,6 +114,11 @@ public AppMaster() { schemaTo = new JTextField(); progressText = new JTextArea(); + //progressText.setLineWrap(true); + //progressText.getScro + progressText.setEditable(false); + JScrollPane scroll_prog = new JScrollPane(progressText); + scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); progressLbl = new JLabel(prop.getProperty("TableauEditor.Label.ProgressLog")); @@ -132,7 +138,7 @@ public AppMaster() { .addComponent(connectionFrom) .addComponent(schemaFrom) .addComponent(okbtn) - .addComponent(progressText,GroupLayout.DEFAULT_SIZE, 200, GroupLayout.DEFAULT_SIZE) + .addComponent(scroll_prog) ) .addGroup(gl.createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(browsebtn) @@ -175,13 +181,13 @@ public AppMaster() { ) .addGroup(gl.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(progressLbl) - .addComponent(progressText) + .addComponent(scroll_prog) ) ); jf.setVisible(true); - jf.setSize(700, 500); + jf.setSize(800, 600); jf.setIconImage(img.getImage()); //jf.pack(); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -300,9 +306,10 @@ public void actionPerformed(ActionEvent e) { }else { message_file += prop.getProperty("TableauEditor.Message.RebuildFailure")+System.lineSeparator(); } - progressText.setText(message_file); - progressText.setText(prop.getProperty("TableauEditor.Message.ProcessingEnd")); + // final end message + message_file += prop.getProperty("TableauEditor.Message.ProcessingEnd")+System.lineSeparator(); + progressText.setText(message_file); } diff --git a/src/main/java/org/tableau/editor/build/BuildContent.java b/src/main/java/org/tableau/editor/build/BuildContent.java index 53b651d..c1aa511 100644 --- a/src/main/java/org/tableau/editor/build/BuildContent.java +++ b/src/main/java/org/tableau/editor/build/BuildContent.java @@ -10,14 +10,17 @@ Tableau Editor Copyright (C) 2018 Rishu Kumar Shrivastava (rishu.shrivastava@g */ package org.tableau.editor.build; -import java.io.File; import java.io.IOException; +import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; + /** * Zip the file back after the editing. * @author Rishu Shrivastava (rishu.shrivastava@gmail.com) @@ -30,6 +33,7 @@ public class BuildContent { public boolean buildContent(String sourcedirpath, String Zipfilepath) { + Path p; try { p = Files.createFile(Paths.get(Zipfilepath)); @@ -49,15 +53,43 @@ public boolean buildContent(String sourcedirpath, String Zipfilepath) { } }); } - + } catch (IOException e1) { e1.printStackTrace(); return false; } - + //cleanup source directory path - new File(sourcedirpath).deleteOnExit(); - + if(!deleteDir(sourcedirpath)) { + return false; + } + + return true; + } + + public boolean deleteDir(String sourcepath) { + //delete the path recursively + Path p = Paths.get(sourcepath); + try { + Files.walkFileTree(p, new SimpleFileVisitor(){ + + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + + Files.delete(dir); + return FileVisitResult.CONTINUE; + } + }); + } catch (IOException e) { + e.printStackTrace(); + return false; + } return true; } } \ No newline at end of file diff --git a/src/main/java/org/tableau/editor/build/ReplaceContent.java b/src/main/java/org/tableau/editor/build/ReplaceContent.java index c48594f..c16ea04 100644 --- a/src/main/java/org/tableau/editor/build/ReplaceContent.java +++ b/src/main/java/org/tableau/editor/build/ReplaceContent.java @@ -47,8 +47,9 @@ public boolean replacecontent(String filename, String outputeditfile, String con String connectionTo, String schemaFrom, String schemaTo) { ArrayList xml_param = new ArrayList<>(); - xml_param.add(0,"/workbook/datasources/datasource/connection/named-connections/named-connection/connection/@filename"); - xml_param.add(1,"/workbook/datasources/datasource/connection/named-connections/named-connection/@caption"); + xml_param.add(0,"/workbook/datasources/datasource/connection/named-connections/named-connection/connection/@server"); + xml_param.add(1,"/workbook/datasources/datasource/connection/named-connections/named-connection/connection/@schema"); + xml_param.add(2,"/workbook/datasources/datasource/connection/named-connections/named-connection/@caption"); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try {