diff --git a/src/main/java/Controller.java b/src/main/java/Controller.java index 6bbb6a6..742115b 100644 --- a/src/main/java/Controller.java +++ b/src/main/java/Controller.java @@ -34,6 +34,7 @@ public class Controller{ @FXML private MenuItem editPreferences; @FXML private TreeView dirTree; @FXML private MenuItem toolsTagFiles; + @FXML private MenuItem toolsDeleteTags; @FXML private ResourceBundle resources; @FXML private void initialize() { @@ -54,20 +55,26 @@ public void handle(MouseEvent args) { }); - /** - Testing tagging. Be careful with this, tag removal is not implemented yet. - */ + toolsTagFiles.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { - - //manager.setFileAttrForSelected(); - manager.getFileAttrForSelected(); + manager.setFileAttrForSelected(); } + }); + + toolsDeleteTags.setOnAction(new EventHandler() { + + @Override + public void handle(ActionEvent event) { + + manager.deleteFileAttrForSelected(); + + } }); diff --git a/src/main/java/FolderViewManager.java b/src/main/java/FolderViewManager.java index 08a5ef8..17f6034 100644 --- a/src/main/java/FolderViewManager.java +++ b/src/main/java/FolderViewManager.java @@ -80,6 +80,16 @@ public void getFileAttrForSelected() { } + public void deleteFileAttrForSelected() { + + for(TreeItem item : selectedFiles) { + + deleteFileAttr(item.getValue(), "test_attr_key"); + + } + + } + public void setFileAttr(IronFile file, String key, String value) { if(OSDetection.OSType == OSDetection.OS.WINDOWS) { @@ -155,13 +165,14 @@ public String getFileAttr(IronFile file, String key) { } - public String removeFileAttr(IronFile file, String key) { + public void deleteFileAttr(IronFile file, String key) { if(OSDetection.OSType == OSDetection.OS.WINDOWS) { try { - return (String) Files.getAttribute(file.toPath(), key); + UserDefinedFileAttributeView view = Files.getFileAttributeView(file.toPath(), UserDefinedFileAttributeView.class); + view.delete(key); } catch(IOException e) { e.printStackTrace(); } @@ -169,25 +180,18 @@ public String removeFileAttr(IronFile file, String key) { System.out.println("file path: " + file.getAbsolutePath()); - String option = ""; - if(file.isDirectory()) { - //option = "-r"; - } - - - String cmd = "xattr -p " + option + " " + key + " " + file.getAbsolutePath(); //then append the attr command + String cmd = "xattr -d " + key + " " + file.getAbsolutePath(); //then append the attr command try { String output = command.run(cmd); + } catch(IOException e) { e.printStackTrace(); } } - return null; - } } diff --git a/src/main/resources/StartPage.fxml b/src/main/resources/StartPage.fxml index 2db9ae1..9b538e3 100644 --- a/src/main/resources/StartPage.fxml +++ b/src/main/resources/StartPage.fxml @@ -23,7 +23,7 @@ - +