Added python project; fixed spelling of folder
This commit is contained in:
199
Java Projects/UDE/UFM/src/Controller.java
Normal file
199
Java Projects/UDE/UFM/src/Controller.java
Normal file
@@ -0,0 +1,199 @@
|
||||
package com.itdominator.ufm;
|
||||
|
||||
import com.itdominator.ufm.Utils.Settings;
|
||||
import com.itdominator.ufm.TabSystem.TabView;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.SplitPane;
|
||||
|
||||
import javafx.scene.input.DragEvent;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.Node;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
|
||||
public class Controller {
|
||||
// Classes
|
||||
private Settings settings = Settings.getInstance();
|
||||
|
||||
// FXML stuff
|
||||
@FXML private HBox masterMenu;
|
||||
@FXML private Button tgglPane2Bttn, tgglPane3Bttn, tgglPane4Bttn;
|
||||
@FXML private AnchorPane masterBase, base1, base2, base3, base4, splitPaneBottomAnchor;
|
||||
@FXML private SplitPane masterSplitPane, splitPaneTop, splitPaneBottom;
|
||||
@FXML private TabPane tabPane1, tabPane2, tabPane3, tabPane4;
|
||||
|
||||
// Generics
|
||||
private static Node pane2Node, pane3Node, pane4Node, masterTopNode, masterBottomNode;
|
||||
private static boolean stateOfCol2 = true, stateOfCol3 = true,
|
||||
stateOfCol4 = true, botomRowInserted = true;
|
||||
private static int bottomCount = 2, selectedTabView;
|
||||
private static final String homeDir = System.getProperty("user.home");;
|
||||
private static final Timer garbageTimer = new Timer();
|
||||
|
||||
private TabView tabView;
|
||||
private Tab tab;
|
||||
|
||||
|
||||
@FXML void initialize() {
|
||||
assert masterBase != null : "fx:id=\"masterBase\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert masterMenu != null : "fx:id=\"masterMenu\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert tgglPane2Bttn != null : "fx:id=\"tgglPane2Bttn\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert tgglPane3Bttn != null : "fx:id=\"tgglPane3Bttn\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert tgglPane4Bttn != null : "fx:id=\"tgglPane4Bttn\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert splitPaneTop != null : "fx:id=\"splitPaneTop\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert base1 != null : "fx:id=\"base1\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert tabPane1 != null : "fx:id=\"tabPane1\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert base2 != null : "fx:id=\"base2\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert tabPane2 != null : "fx:id=\"tabPane2\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert splitPaneBottom != null : "fx:id=\"splitPaneBottom\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert base3 != null : "fx:id=\"base3\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert tabPane3 != null : "fx:id=\"tabPane3\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert base4 != null : "fx:id=\"base4\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert tabPane4 != null : "fx:id=\"tabPane4\" was not injected: check your FXML file 'window.fxml'.";
|
||||
|
||||
masterTopNode = masterSplitPane.getItems().get(0); // In slot "1" of masterSplitPane
|
||||
masterBottomNode = masterSplitPane.getItems().get(1); // In slot "2" of masterSplitPane
|
||||
pane2Node = splitPaneTop.getItems().get(1); // In slot 2 of splitPaneTop
|
||||
pane3Node = splitPaneBottom.getItems().get(0); // In slot "1" of splitPaneBottom
|
||||
pane4Node = splitPaneBottom.getItems().get(1); // In slot "2" of splitPaneBottom
|
||||
|
||||
setTimeTasks(); // Garbage collection
|
||||
setClickEvents();
|
||||
loadDefaultPanes();
|
||||
}
|
||||
|
||||
// Add new tab to location
|
||||
@FXML void newTab(MouseEvent mouseEvent) {
|
||||
if(mouseEvent.getClickCount() == 1 && mouseEvent.isControlDown() ) {
|
||||
generateTab();
|
||||
}
|
||||
}
|
||||
|
||||
// Make new tabs
|
||||
void generateTab() {
|
||||
tab = new Tab(homeDir);
|
||||
tabView = new TabView();
|
||||
tabView.setDirLoc(homeDir);
|
||||
tabView.startIconGeneration();
|
||||
|
||||
tab.setContent(tabView.getContent());
|
||||
|
||||
if (selectedTabView == 1) {
|
||||
tabPane1.getTabs().add(tab);
|
||||
tabPane1.getSelectionModel().select(tab);
|
||||
} else if (selectedTabView == 2) {
|
||||
tabPane2.getTabs().add(tab);
|
||||
tabPane2.getSelectionModel().select(tab);
|
||||
} else if (selectedTabView == 3) {
|
||||
tabPane3.getTabs().add(tab);
|
||||
tabPane3.getSelectionModel().select(tab);
|
||||
} else if (selectedTabView == 4) {
|
||||
tabPane4.getTabs().add(tab);
|
||||
tabPane4.getSelectionModel().select(tab);
|
||||
}
|
||||
}
|
||||
|
||||
@FXML void openLocation(DragEvent event) {
|
||||
// tabs will open folder locations in selected tab if drag in is folder
|
||||
}
|
||||
|
||||
// Sets upo the hide buttons top right.
|
||||
private void setClickEvents() {
|
||||
tgglPane2Bttn.setOnAction(col2 -> {
|
||||
if (stateOfCol2 == true) {
|
||||
splitPaneTop.getItems().remove(pane2Node);
|
||||
splitPaneTop.setDividerPositions(0.5f, 0.0f);
|
||||
stateOfCol2 = false;
|
||||
tgglPane2Bttn.setStyle("-fx-background-color: #880000;");
|
||||
} else {
|
||||
splitPaneTop.getItems().add(pane2Node);
|
||||
splitPaneTop.setDividerPositions(0.5f, 0.10f);
|
||||
stateOfCol2 = true;
|
||||
tgglPane2Bttn.setStyle("-fx-background-color: #008800;");
|
||||
}
|
||||
});
|
||||
tgglPane3Bttn.setOnAction(col3 -> {
|
||||
if (stateOfCol3 == true) {
|
||||
splitPaneBottom.getItems().remove(pane3Node);
|
||||
splitPaneBottom.setDividerPositions(0.0f, 0.10f);
|
||||
bottomCount -= 1;
|
||||
stateOfCol3 = false;
|
||||
horizontalBarState();
|
||||
tgglPane3Bttn.setStyle("-fx-background-color: #880000;");
|
||||
} else {
|
||||
splitPaneBottom.getItems().add(pane3Node);
|
||||
splitPaneBottom.setDividerPositions(0.5f, 0.10f);
|
||||
stateOfCol3 = true;
|
||||
bottomCount += 1;
|
||||
horizontalBarState();
|
||||
tgglPane3Bttn.setStyle("-fx-background-color: #008800;");
|
||||
}
|
||||
});
|
||||
tgglPane4Bttn.setOnAction(col4 -> {
|
||||
if (stateOfCol4 == true) {
|
||||
splitPaneBottom.getItems().remove(pane4Node);
|
||||
splitPaneBottom.setDividerPositions(0.5f, 0.0f);
|
||||
bottomCount -= 1;
|
||||
stateOfCol4 = false;
|
||||
horizontalBarState();
|
||||
tgglPane4Bttn.setStyle("-fx-background-color: #880000;");
|
||||
} else {
|
||||
splitPaneBottom.getItems().add(pane4Node);
|
||||
splitPaneBottom.setDividerPositions(0.5f, 0.10f);
|
||||
stateOfCol4 = true;
|
||||
bottomCount += 1;
|
||||
horizontalBarState();
|
||||
tgglPane4Bttn.setStyle("-fx-background-color: #008800;");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Do periodic garbage collection.
|
||||
private void setTimeTasks() {
|
||||
garbageTimer.schedule(new TimerTask() { public void run() {
|
||||
System.gc();
|
||||
}}, 1, 10500);
|
||||
// Need to properly close this.... upon system close
|
||||
}
|
||||
|
||||
// On start of file manager.
|
||||
// Need to eventually check settings to load sessions...
|
||||
private void loadDefaultPanes() {
|
||||
selectedTabView = 1;
|
||||
generateTab();
|
||||
selectedTabView = 2;
|
||||
generateTab();
|
||||
selectedTabView = 3;
|
||||
generateTab();
|
||||
selectedTabView = 4;
|
||||
generateTab();
|
||||
}
|
||||
|
||||
// Determin if bottom two panes are shown or not
|
||||
private void horizontalBarState() {
|
||||
if (bottomCount == 0) {
|
||||
masterSplitPane.getItems().remove(masterBottomNode);
|
||||
botomRowInserted = false;
|
||||
} else if (bottomCount == 1 && botomRowInserted != true) {
|
||||
masterSplitPane.getItems().add(masterBottomNode);
|
||||
botomRowInserted = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Used so that we can call proper add option for tabinsert
|
||||
@FXML void setSelectedTo1(MouseEvent event) { selectedTabView = 1; }
|
||||
@FXML void setSelectedTo2(MouseEvent event) { selectedTabView = 2; }
|
||||
@FXML void setSelectedTo3(MouseEvent event) { selectedTabView = 3; }
|
||||
@FXML void setSelectedTo4(MouseEvent event) { selectedTabView = 4; }
|
||||
}
|
200
Java Projects/UDE/UFM/src/TabSystem/Icon.java
Normal file
200
Java Projects/UDE/UFM/src/TabSystem/Icon.java
Normal file
@@ -0,0 +1,200 @@
|
||||
package com.itdominator.ufm.TabSystem;
|
||||
|
||||
import com.itdominator.ufm.ThumbnailSystem.Thumbnail;
|
||||
|
||||
import javafx.stage.Stage;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.Cursor;
|
||||
import java.util.Scanner;
|
||||
import java.io.File;
|
||||
|
||||
import javafx.scene.layout.TilePane;
|
||||
import javafx.scene.control.TextField;
|
||||
|
||||
|
||||
public class Icon extends TabView {
|
||||
// Class objects
|
||||
private Thumbnail thumbnail = new Thumbnail();
|
||||
|
||||
// Generics
|
||||
private TilePane tilePane = new TilePane();
|
||||
private TextField txtDirPath = new TextField();
|
||||
|
||||
private VBox icon = new VBox();
|
||||
private Image img;
|
||||
private ImageView imgView = new ImageView();
|
||||
private Label title = new Label("");
|
||||
private Tooltip tooltip;
|
||||
private Process pb; // Process runner
|
||||
private Scanner scanner;
|
||||
private File file;
|
||||
private boolean isDir = false, isImage = false;
|
||||
|
||||
private String containsStr = System.getProperty("user.home")+ "/Desktop/",
|
||||
toLaunch = "", runCommand = "", thumbImg = "",
|
||||
toShellOut = "", toShellExec = "", line = "",
|
||||
path = "", name = "";
|
||||
private double orgSceneX, orgSceneY, orgTranslateX, orgTranslateY;
|
||||
|
||||
public VBox getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void createIcon(String pth, String nme) {
|
||||
icon.getStyleClass().add("icon");
|
||||
|
||||
path = pth;
|
||||
name = nme;
|
||||
|
||||
// Creates Icon parts for desktop and sets click actions
|
||||
getIconImg();
|
||||
mergeIconParts();
|
||||
setExecuteModel();
|
||||
setIconEvents();
|
||||
}
|
||||
|
||||
private void getIconImg() {
|
||||
thumbnail.setIconImg(path, name);
|
||||
thumbImg = thumbnail.getIconImg();
|
||||
if (thumbImg.contains("systemFile.png")) {
|
||||
if (name.matches("^.*?(doc|docx|odf).*$")) {
|
||||
imgView.getStyleClass().add("icon-document");
|
||||
} else if (name.matches("^.*?(pps|ppt|pptx).*$")) {
|
||||
imgView.getStyleClass().add("icon-presentation");
|
||||
} else if (name.matches("^.*?(xls|xlsx|csv).*$")) {
|
||||
imgView.getStyleClass().add("icon-spreadsheet");
|
||||
} else if (name.matches("^.*?(mp2|mp3|ogg).*$")) {
|
||||
imgView.getStyleClass().add("icon-music");
|
||||
} else if (name.matches("^.*?(txt|sh|link).*$")) {
|
||||
imgView.getStyleClass().add("icon-text");
|
||||
} else if (name.matches("^.*?(run|bin|jar).*$")) {
|
||||
imgView.getStyleClass().add("icon-bin");
|
||||
} else if (name.matches("^.*?(zip|7zip|rar|tar|tar.gz|gz).*$")) {
|
||||
imgView.getStyleClass().add("icon-compressed");
|
||||
} else if (name.matches("^.*?(html|xml|htm|css).*$")) {
|
||||
imgView.getStyleClass().add("icon-web");
|
||||
} else {
|
||||
imgView.getStyleClass().add("icon-folder");
|
||||
}
|
||||
} else if (name.matches("^.*?(png|svg|jpg|jpeg|tiff|gif).*$")) {
|
||||
placeImage();
|
||||
isImage = true;
|
||||
} else { placeImage(); }
|
||||
imgView.setCache(true); // Improves responsiveness when there are many images
|
||||
}
|
||||
|
||||
private void placeImage() {
|
||||
img = new Image("file:" + thumbImg);
|
||||
imgView.setImage(img);
|
||||
imgView.setFitWidth(96.0);
|
||||
imgView.setFitHeight(96.0);
|
||||
}
|
||||
|
||||
private void mergeIconParts() {
|
||||
title.setMaxWidth(150); // Based On Character Count??
|
||||
title.setText(name);
|
||||
tooltip = new Tooltip(name);
|
||||
tooltip.minHeight(800);
|
||||
tooltip.minWidth(800);
|
||||
Tooltip.install(icon, tooltip);
|
||||
icon.getChildren().addAll(imgView, title); // Insert image and name to icon VBox container
|
||||
}
|
||||
|
||||
private void setExecuteModel() {
|
||||
// Set file execution for .desktop files and directories else use xdg-open
|
||||
toLaunch = path;
|
||||
file = new File(path);
|
||||
if (path.contains(".desktop")) {
|
||||
try {
|
||||
scanner = new Scanner(file);
|
||||
while(scanner.hasNext()) {
|
||||
line = scanner.nextLine();
|
||||
if(line.contains("Exec=")) {
|
||||
toShellOut = line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch(Throwable lineErr) {
|
||||
System.out.println("Failed To Get Exec Info: " + lineErr);
|
||||
}
|
||||
|
||||
if (toShellOut.contains("TryExec="))
|
||||
toShellOut = toShellOut.replaceAll("TryExec=","");
|
||||
else if (toShellOut.contains("Exec="))
|
||||
toShellOut = toShellOut.replaceAll("Exec=","");
|
||||
runCommand = toShellOut;
|
||||
} else if (!file.isFile()) {
|
||||
isDir = true;
|
||||
}
|
||||
else {
|
||||
runCommand = "xdg-open " + toLaunch;
|
||||
}
|
||||
}
|
||||
|
||||
private void setIconEvents() {
|
||||
icon.addEventFilter(MouseEvent.MOUSE_PRESSED,
|
||||
new EventHandler<MouseEvent>() {
|
||||
@Override public void handle(MouseEvent click) {
|
||||
if (click.getClickCount() == 2) {
|
||||
click.consume();
|
||||
if (isDir == true) {
|
||||
if (path.equals("..")) {
|
||||
path = txtDirPath.getText();
|
||||
int start = 0, end = path.length() - 1;
|
||||
for (int i=end; i>0; i--) {
|
||||
if (path.charAt(i) == '/') {
|
||||
start = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
path = path.substring(0, start);
|
||||
setTabView(path, tilePane, txtDirPath);
|
||||
} else {
|
||||
System.out.println(path);
|
||||
setTabView(path, tilePane, txtDirPath);
|
||||
}
|
||||
} else if (isImage == true) {
|
||||
openImage();
|
||||
} else {
|
||||
try {
|
||||
System.out.println(runCommand);
|
||||
pb = Runtime.getRuntime().exec(runCommand);
|
||||
} catch(Throwable imgIOErr) {
|
||||
System.out.println(imgIOErr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void openImage() {
|
||||
Stage imagStage = new Stage();
|
||||
Pane pane = new Pane();
|
||||
ImageView iView = new ImageView(img);
|
||||
pane.getChildren().add(iView);
|
||||
iView.setLayoutX(0);
|
||||
iView.setLayoutY(0);
|
||||
iView.fitWidthProperty().bind(pane.widthProperty());
|
||||
iView.fitHeightProperty().bind(pane.heightProperty());
|
||||
iView.setPreserveRatio(true);
|
||||
Scene scene = new Scene(pane, 800, 800);
|
||||
imagStage.setTitle("" + img);
|
||||
imagStage.setScene(scene);
|
||||
imagStage.show();
|
||||
}
|
||||
|
||||
protected void setWorkingTab(TilePane tP, TextField tF) {
|
||||
this.tilePane = tP;
|
||||
this.txtDirPath = tF;
|
||||
}
|
||||
}
|
100
Java Projects/UDE/UFM/src/TabSystem/TabView.java
Normal file
100
Java Projects/UDE/UFM/src/TabSystem/TabView.java
Normal file
@@ -0,0 +1,100 @@
|
||||
package com.itdominator.ufm.TabSystem;
|
||||
|
||||
import com.itdominator.ufm.Controller;
|
||||
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.TilePane;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.geometry.Pos;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
public class TabView extends Controller {
|
||||
// Tab Info
|
||||
private AnchorPane anchorPane = new AnchorPane();
|
||||
private ScrollPane scrollPane = new ScrollPane();
|
||||
private TilePane tilePane = new TilePane();
|
||||
private TextField txtDirPath = new TextField();
|
||||
private VBox iconVBox;
|
||||
|
||||
private ImageView imgView;
|
||||
private Label dir, fileName;
|
||||
private static File[] fileList;
|
||||
private static File directory;
|
||||
private static String loadPath;
|
||||
private static final String homeDir = System.getProperty("user.home");;
|
||||
private static boolean showHidden = false;
|
||||
private Tab tab = new Tab();
|
||||
|
||||
public TabView() {
|
||||
anchorPane.getChildren().addAll(txtDirPath, scrollPane);
|
||||
anchorPane.setTopAnchor(txtDirPath, 0.0);
|
||||
anchorPane.setLeftAnchor(txtDirPath, 0.0);
|
||||
anchorPane.setRightAnchor(txtDirPath, 0.0);
|
||||
anchorPane.setTopAnchor(scrollPane, 30.0);
|
||||
anchorPane.setLeftAnchor(scrollPane, 0.0);
|
||||
anchorPane.setRightAnchor(scrollPane, 0.0);
|
||||
anchorPane.setBottomAnchor(scrollPane, 0.0);
|
||||
scrollPane.setFitToWidth(true);
|
||||
scrollPane.setContent(tilePane);
|
||||
txtDirPath.setText(homeDir);
|
||||
txtDirPath.getStyleClass().add("fileURLField");
|
||||
tilePane.getStyleClass().add("tile-pane");
|
||||
tilePane.setMaxWidth(Region.USE_PREF_SIZE);
|
||||
}
|
||||
|
||||
public AnchorPane getContent() { return anchorPane; }
|
||||
public void setDirLoc(String loadPath) { this.loadPath = loadPath; }
|
||||
|
||||
public void startIconGeneration() {
|
||||
generateIcons();
|
||||
}
|
||||
|
||||
private void generateIcons() {
|
||||
directory = new File(txtDirPath.getText());
|
||||
fileList = directory.listFiles();
|
||||
for (int i=-1; i<fileList.length; i++) {
|
||||
if (i==-1) { // Insert .. to go up
|
||||
final Icon icon = new Icon();
|
||||
icon.setWorkingTab(tilePane, txtDirPath);
|
||||
final String fileName = "..", file = "..";
|
||||
icon.createIcon(file, fileName);
|
||||
tilePane.getChildren().add(icon.getIcon());
|
||||
i = 0;
|
||||
} else {
|
||||
final Icon icon = new Icon();
|
||||
icon.setWorkingTab(tilePane, txtDirPath);
|
||||
final String fileName = "" + fileList[i].getName(),
|
||||
file = "" + fileList[i];
|
||||
if (showHidden != true) {
|
||||
if (fileName.charAt(0) != '.') {
|
||||
icon.createIcon(file, fileName);
|
||||
tilePane.getChildren().add(icon.getIcon());
|
||||
}
|
||||
} else {
|
||||
icon.createIcon(file, fileName);
|
||||
tilePane.getChildren().add(icon.getIcon());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void setTabView(String path, TilePane tP, TextField tF) {
|
||||
this.tilePane = tP;
|
||||
this.txtDirPath = tF;
|
||||
tilePane.getChildren().clear();
|
||||
txtDirPath.setText(path);
|
||||
generateIcons();
|
||||
}
|
||||
|
||||
protected void setShowHiddenState(boolean state) {
|
||||
showHidden = state;
|
||||
}
|
||||
}
|
28
Java Projects/UDE/UFM/src/ThumbnailSystem/CleanPath.java
Normal file
28
Java Projects/UDE/UFM/src/ThumbnailSystem/CleanPath.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.itdominator.ufm.ThumbnailSystem;
|
||||
|
||||
|
||||
// Clear file of special characters and spaces
|
||||
import java.io.File;
|
||||
|
||||
public class CleanPath {
|
||||
private static String preLine = "";
|
||||
|
||||
public String cleanThumbPth(String tmp) {
|
||||
File f = new File(tmp);
|
||||
|
||||
// if it's a directory, don't remove the extention
|
||||
if (f.isDirectory()) System.out.println("This is a a directory.");
|
||||
String name = f.getName();
|
||||
final int lastPeriodPos = name.lastIndexOf('.');
|
||||
if (lastPeriodPos <= 0) {
|
||||
preLine = "" + name;
|
||||
} else {
|
||||
// Remove the last period and everything after it
|
||||
File renamed = new File(f.getParent(), name.substring(0, lastPeriodPos));
|
||||
preLine = "" + renamed;
|
||||
preLine = preLine.replaceAll("[^A-Za-z]+", "");
|
||||
preLine = preLine.replaceAll("\\s+","");
|
||||
}
|
||||
return preLine;
|
||||
}
|
||||
}
|
73
Java Projects/UDE/UFM/src/ThumbnailSystem/Thumbnail.java
Normal file
73
Java Projects/UDE/UFM/src/ThumbnailSystem/Thumbnail.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package com.itdominator.ufm.ThumbnailSystem;
|
||||
|
||||
|
||||
// Generates the actual image of the icon.
|
||||
import java.util.Scanner;
|
||||
import java.io.File;
|
||||
import java.lang.Runtime;
|
||||
|
||||
|
||||
public class Thumbnail {
|
||||
// Class objects
|
||||
private CleanPath cleaner = new CleanPath(); // Cleans thumbnail names
|
||||
private ThumbnailGenerator vidThumbnailGen = new ThumbnailGenerator();
|
||||
|
||||
// Generics
|
||||
private static File highColorDir = new File(System.getProperty("user.home") +
|
||||
"/.local/share/icons/hicolor/256x256/apps/"),
|
||||
localApplicationsDir = new File(System.getProperty("user.home") +
|
||||
"/.local/share/applications/");
|
||||
private static File[] highColorDirList = highColorDir.listFiles(),
|
||||
localApplicationsDirList = localApplicationsDir.listFiles();
|
||||
|
||||
// Generics
|
||||
private static Scanner scanner;
|
||||
private static File file;
|
||||
private static String thumbImg = "", line = "", temp = "";
|
||||
|
||||
|
||||
public String getIconImg() {
|
||||
return thumbImg;
|
||||
}
|
||||
|
||||
public void setIconImg(String path, String name) {
|
||||
temp = path.toLowerCase();
|
||||
|
||||
if (temp.matches("^.*?(avi|webm|mpeg|mpg|mkv|flv|wmv|mp4).*$")) {
|
||||
thumbImg = vidThumbnailGen.generateThumb(path, cleaner.cleanThumbPth(name));
|
||||
} else if (temp.matches("^.*?(png|svg|jpg|jpeg|tiff|gif).*$")) {
|
||||
thumbImg = path;
|
||||
} else if (temp.contains(".desktop")) {
|
||||
file = new File(path);
|
||||
try {
|
||||
scanner = new Scanner(file);
|
||||
while(scanner.hasNext()) {
|
||||
line = scanner.nextLine();
|
||||
if(line.contains("Icon=")) {
|
||||
thumbImg = line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch(Throwable lineErr) {
|
||||
System.out.println("Failed To Get Icon: " + lineErr);
|
||||
}
|
||||
thumbImg = thumbImg.replaceAll("Icon=",""); // Strip Icon= from the icon info
|
||||
|
||||
// Steam Icons
|
||||
if (thumbImg.contains("steam_icon")) {
|
||||
for (int i=0; i<highColorDirList.length; i++) {
|
||||
if (highColorDirList[i].toString().contains(thumbImg)) {
|
||||
thumbImg = "" + highColorDirList[i];
|
||||
}
|
||||
}
|
||||
for (int i=0; i<localApplicationsDirList.length; i++) {
|
||||
if (localApplicationsDirList[i].toString().contains(thumbImg)) {
|
||||
thumbImg = "" + localApplicationsDirList[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
thumbImg = "resources/generic-theme/systemFile.png";
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.itdominator.ufm.ThumbnailSystem;
|
||||
|
||||
|
||||
// Generate Thumbnails for videos with ffmpegthumbnailer
|
||||
|
||||
public class ThumbnailGenerator {
|
||||
private Process pb; // Process runner
|
||||
private String thumbName, genCommand;
|
||||
|
||||
public String generateThumb(String file, String thumb) {
|
||||
thumbName = thumb;
|
||||
genCommand = "ffmpegthumbnailer -w -t='00:30:00' -c png -i " +
|
||||
file + " -s 300 -o " + "thumbs/" + thumbName + ".png";
|
||||
try {
|
||||
pb = Runtime.getRuntime().exec(genCommand);
|
||||
pb.waitFor();
|
||||
} catch(Throwable imgIOErr) {
|
||||
System.out.println(imgIOErr);
|
||||
}
|
||||
thumbName = "./thumbs/" + thumbName + ".png";
|
||||
return thumbName;
|
||||
}
|
||||
}
|
38
Java Projects/UDE/UFM/src/UFM.java
Normal file
38
Java Projects/UDE/UFM/src/UFM.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.itdominator.ufm;
|
||||
|
||||
import com.itdominator.ufm.Utils.UFMLogger;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.image.Image;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class UFM extends Application {
|
||||
// Classes
|
||||
private UFMLogger ufmLogger = UFMLogger.getInstance();
|
||||
|
||||
@Override public void start(Stage stage) {
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("resources/UFM_Win.fxml"));
|
||||
loader.setController(new Controller());
|
||||
loader.load();
|
||||
Scene scene = new Scene(loader.getRoot());
|
||||
scene.getStylesheets().add("/com/itdominator/ufm/resources/stylesheet.css");
|
||||
stage.setTitle("UFM");
|
||||
stage.setScene(scene);
|
||||
} catch (IOException startException) {
|
||||
String message = "\nUFM Failed to launch...\n";
|
||||
System.out.println(message + startException);
|
||||
ufmLogger.insertToLog(Level.SEVERE, message, startException);
|
||||
}
|
||||
stage.getIcons().add(new Image(UFM.class.getResourceAsStream("resources/UFM.png")));
|
||||
stage.setResizable(false);
|
||||
stage.show();
|
||||
}
|
||||
public static void main(String[] args) { launch(args); }
|
||||
}
|
18
Java Projects/UDE/UFM/src/Utils/Settings.java
Normal file
18
Java Projects/UDE/UFM/src/Utils/Settings.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.itdominator.ufm.Utils;
|
||||
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
|
||||
public class Settings {
|
||||
private static Settings settings = new Settings();
|
||||
|
||||
private Settings() {
|
||||
|
||||
}
|
||||
|
||||
public static Settings getInstance() { return settings; }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
31
Java Projects/UDE/UFM/src/Utils/UFMLogger.java
Normal file
31
Java Projects/UDE/UFM/src/Utils/UFMLogger.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.itdominator.ufm.Utils;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class UFMLogger {
|
||||
private static UFMLogger ufmLogger = new UFMLogger();
|
||||
private Logger logger = Logger.getLogger(UFMLogger.class.getName());
|
||||
private boolean append = false;
|
||||
|
||||
// Instance passer
|
||||
public static UFMLogger getInstance() { return ufmLogger; }
|
||||
|
||||
// Init UFMLogger
|
||||
private UFMLogger() {
|
||||
try {
|
||||
FileHandler logFile = new FileHandler("ufm_error.log", append);
|
||||
logger.addHandler(logFile);
|
||||
} catch (IOException e) {
|
||||
insertToLog(Level.SEVERE, "Can not access error log file...", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void insertToLog(Level severity, String message, Exception stackTrace) {
|
||||
logger.log(severity, message, stackTrace);
|
||||
}
|
||||
}
|
BIN
Java Projects/UDE/UFM/src/unix_compile.sh
Executable file
BIN
Java Projects/UDE/UFM/src/unix_compile.sh
Executable file
Binary file not shown.
Reference in New Issue
Block a user