Skip to content

Commit

Permalink
Added function to remove tags
Browse files Browse the repository at this point in the history
  • Loading branch information
kag12017 committed Feb 29, 2016
1 parent 4fbd297 commit 063fc09
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
19 changes: 13 additions & 6 deletions src/main/java/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class Controller{
@FXML private MenuItem editPreferences;
@FXML private TreeView<IronFile> dirTree;
@FXML private MenuItem toolsTagFiles;
@FXML private MenuItem toolsDeleteTags;
@FXML private ResourceBundle resources;

@FXML private void initialize() {
Expand All @@ -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<ActionEvent>() {

@Override
public void handle(ActionEvent event) {


//manager.setFileAttrForSelected();
manager.getFileAttrForSelected();
manager.setFileAttrForSelected();

}

});

toolsDeleteTags.setOnAction(new EventHandler<ActionEvent>() {

@Override
public void handle(ActionEvent event) {

manager.deleteFileAttrForSelected();

}

});

Expand Down
26 changes: 15 additions & 11 deletions src/main/java/FolderViewManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ public void getFileAttrForSelected() {

}

public void deleteFileAttrForSelected() {

for(TreeItem<IronFile> item : selectedFiles) {

deleteFileAttr(item.getValue(), "test_attr_key");

}

}

public void setFileAttr(IronFile file, String key, String value) {

if(OSDetection.OSType == OSDetection.OS.WINDOWS) {
Expand Down Expand Up @@ -155,39 +165,33 @@ 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(); }

} else if(OSDetection.OSType == OSDetection.OS.MAC) {

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;

}

}
2 changes: 1 addition & 1 deletion src/main/resources/StartPage.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<items>
<MenuItem mnemonicParsing="false" text="Search" />
<MenuItem id="tagFilesButton" fx:id="toolsTagFiles" mnemonicParsing="false" text="Tag Files" />
<MenuItem mnemonicParsing="false" text="Auto Manager" />
<MenuItem id="deleteTagsButton" fx:id="toolsDeleteTags" mnemonicParsing="false" text="Delete Tags" />
<MenuItem mnemonicParsing="false" text="Templates" />
</items>
</Menu>
Expand Down

0 comments on commit 063fc09

Please sign in to comment.