Skip to content

Commit

Permalink
Fixing the resource file and delete option
Browse files Browse the repository at this point in the history
  • Loading branch information
rishuatgithub committed May 9, 2018
1 parent ba9dfbb commit a1ef5ce
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 16 deletions.
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
</archive>
</configuration>
</plugin>

</plugins>
</build>
</project>
23 changes: 15 additions & 8 deletions src/main/java/org/tableau/editor/build/AppMaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -53,14 +53,15 @@ public class AppMaster extends JFrame implements ActionListener {
ArrayList<String> filetoprocess = new ArrayList<String>();

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

Expand Down Expand Up @@ -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"));

Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

}

Expand Down
42 changes: 37 additions & 5 deletions src/main/java/org/tableau/editor/build/BuildContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 ([email protected])
Expand All @@ -30,6 +33,7 @@ public class BuildContent {

public boolean buildContent(String sourcedirpath, String Zipfilepath) {


Path p;
try {
p = Files.createFile(Paths.get(Zipfilepath));
Expand All @@ -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<Path>(){

@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;
}
}
5 changes: 3 additions & 2 deletions src/main/java/org/tableau/editor/build/ReplaceContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ public boolean replacecontent(String filename, String outputeditfile, String con
String connectionTo, String schemaFrom, String schemaTo) {

ArrayList<String> 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 {
Expand Down

0 comments on commit a1ef5ce

Please sign in to comment.