Added python project; fixed spelling of folder
This commit is contained in:
BIN
Java Projects/JPath/bin/JPath.jar
Executable file
BIN
Java Projects/JPath/bin/JPath.jar
Executable file
Binary file not shown.
9
Java Projects/JPath/buildJar.sh
Executable file
9
Java Projects/JPath/buildJar.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
function main() {
|
||||
jar cvfm JPath.jar manifest.txt com/itdominator/jpath/*.class \
|
||||
com/itdominator/jpath/utils/*.class \
|
||||
com/itdominator/jpath/resources
|
||||
chmod +x JPath.jar
|
||||
}
|
||||
main;
|
BIN
Java Projects/JPath/com/itdominator/jpath/Controller.class
Normal file
BIN
Java Projects/JPath/com/itdominator/jpath/Controller.class
Normal file
Binary file not shown.
BIN
Java Projects/JPath/com/itdominator/jpath/JPath.class
Normal file
BIN
Java Projects/JPath/com/itdominator/jpath/JPath.class
Normal file
Binary file not shown.
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
|
||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="650.0" minWidth="350.0" prefHeight="650.0" prefWidth="350.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<ListView fx:id="pathListView" editable="true" layoutX="14.0" layoutY="92.0" prefHeight="543.0" prefWidth="320.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="100.0" />
|
||||
<TextField fx:id="newEntry" layoutX="14.0" layoutY="14.0" onKeyReleased="#addEntryEnter" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="15.0" />
|
||||
<Button layoutX="64.0" layoutY="62.0" mnemonicParsing="false" onAction="#addEntryBttn" text="Add" AnchorPane.leftAnchor="15.0" AnchorPane.topAnchor="60.0" />
|
||||
<Button layoutX="235.0" layoutY="60.0" mnemonicParsing="false" onAction="#delEntry" text="Delete" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="60.0" />
|
||||
<Button layoutX="204.0" layoutY="60.0" mnemonicParsing="false" onAction="#saveEnteriesToPATH" text="Save" AnchorPane.rightAnchor="85.0" AnchorPane.topAnchor="60.0" />
|
||||
<Button layoutX="72.0" layoutY="60.0" mnemonicParsing="false" onAction="#addBack" text="Undo" AnchorPane.leftAnchor="65.0" AnchorPane.topAnchor="60.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
Binary file not shown.
1
Java Projects/JPath/manifest.txt
Normal file
1
Java Projects/JPath/manifest.txt
Normal file
@@ -0,0 +1 @@
|
||||
Main-Class: com.itdominator.jpath.JPath
|
85
Java Projects/JPath/src/Controller.java
Normal file
85
Java Projects/JPath/src/Controller.java
Normal file
@@ -0,0 +1,85 @@
|
||||
package com.itdominator.jpath;
|
||||
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.event.ActionEvent;
|
||||
|
||||
|
||||
import java.lang.System;
|
||||
import java.lang.Process;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class Controller {
|
||||
// Classes
|
||||
|
||||
// FXML Stuff
|
||||
@FXML private ListView<String> pathListView;
|
||||
@FXML private TextField newEntry;
|
||||
|
||||
// Generics
|
||||
private static ArrayList<String> history = new ArrayList<String>();
|
||||
private static ObservableList<String> paths;
|
||||
private static Process proc;
|
||||
|
||||
|
||||
@FXML void initialize() {
|
||||
assert pathListView != null : "fx:id=\"pathListView\" was not injected: check your FXML file 'JPath.fxml'.";
|
||||
assert newEntry != null : "fx:id=\"newEntry\" was not injected: check your FXML file 'JPath.fxml'.";
|
||||
|
||||
paths = FXCollections.observableArrayList(System.getenv("PATH").split(":"));
|
||||
pathListView.setItems(paths);
|
||||
}
|
||||
|
||||
@FXML void addEntryBttn(ActionEvent event) {
|
||||
addEntry();
|
||||
}
|
||||
|
||||
@FXML void addEntryEnter(KeyEvent event) {
|
||||
if (event.getCode() == KeyCode.ENTER) {
|
||||
addEntry();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML void delEntry(ActionEvent event) {
|
||||
int index = pathListView.getSelectionModel().getSelectedIndex();
|
||||
if (index >= 0) {
|
||||
String path = pathListView.getItems().get(index);
|
||||
history.add(path);
|
||||
paths.remove(index);
|
||||
}
|
||||
}
|
||||
|
||||
@FXML void saveEnteriesToPATH(ActionEvent event) throws IOException {
|
||||
String PATH = "bash -c 'export PATH=\"" + String.join(":", paths) + "\" &'";
|
||||
System.out.println(PATH);
|
||||
Runtime.getRuntime().exec(PATH);
|
||||
}
|
||||
|
||||
@FXML void addBack(ActionEvent event) {
|
||||
if ((history.size() - 1) != -1) {
|
||||
String path = history.get(history.size() - 1);
|
||||
paths.addAll(path);
|
||||
history.remove(path);
|
||||
}
|
||||
}
|
||||
|
||||
private void addEntry() {
|
||||
String path = newEntry.getText();
|
||||
|
||||
if (!path.isEmpty()) {
|
||||
if (history.contains(path))
|
||||
history.remove(path);
|
||||
|
||||
paths.add(path);
|
||||
newEntry.setText("");
|
||||
}
|
||||
}
|
||||
}
|
38
Java Projects/JPath/src/JPath.java
Normal file
38
Java Projects/JPath/src/JPath.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.itdominator.jpath;
|
||||
|
||||
import com.itdominator.jpath.utils.JPathLogger;
|
||||
|
||||
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 JPath extends Application {
|
||||
// Classes
|
||||
private JPathLogger jpathLogger = JPathLogger.getInstance();
|
||||
|
||||
@Override public void start(Stage stage) {
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("resources/JPath.fxml"));
|
||||
loader.setController(new Controller());
|
||||
loader.load();
|
||||
Scene scene = new Scene(loader.getRoot());
|
||||
scene.getStylesheets().add("/com/itdominator/jpath/resources/stylesheet.css");
|
||||
stage.setTitle("JPath");
|
||||
stage.setScene(scene);
|
||||
} catch (IOException startException) {
|
||||
String message = "\nJPath Failed to launch...\n";
|
||||
System.out.println(message + startException);
|
||||
jpathLogger.insertToLog(Level.SEVERE, message, startException);
|
||||
}
|
||||
// stage.getIcons().add(new Image(JPath.class.getResourceAsStream("resources/JPath.png")));
|
||||
stage.setResizable(true);
|
||||
stage.show();
|
||||
}
|
||||
public static void main(String[] args) { launch(args); }
|
||||
}
|
12
Java Projects/JPath/src/unix_compile.sh
Executable file
12
Java Projects/JPath/src/unix_compile.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
# -Xlint:unchecked
|
||||
function main() {
|
||||
javac *.java utils/*.java
|
||||
|
||||
rm ../com/itdominator/jpath/*.class
|
||||
rm ../com/itdominator/jpath/utils/*.class
|
||||
|
||||
mv *.class ../com/itdominator/jpath/
|
||||
mv utils/*.class ../com/itdominator/jpath/utils/
|
||||
}
|
||||
main;
|
31
Java Projects/JPath/src/utils/JPathLogger.java
Normal file
31
Java Projects/JPath/src/utils/JPathLogger.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.itdominator.jpath.utils;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class JPathLogger {
|
||||
private static JPathLogger jpathLogger = new JPathLogger();
|
||||
private Logger logger = Logger.getLogger(JPathLogger.class.getName());
|
||||
private boolean append = false;
|
||||
|
||||
// Instance passer
|
||||
public static JPathLogger getInstance() { return jpathLogger; }
|
||||
|
||||
// Init JPathLogger
|
||||
private JPathLogger() {
|
||||
try {
|
||||
FileHandler logFile = new FileHandler("jpath_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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user