Archived
0

Merge branch 'dev-javafx' into dev

# Conflicts:
#	pom.xml
This commit is contained in:
2018-06-03 13:38:37 +03:00
6 changed files with 207 additions and 12 deletions

16
pom.xml
View File

@@ -3,11 +3,20 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>1S Corrector</name>
<groupId>ru.dmitriymx</groupId>
<artifactId>corrector-1s</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<developers>
<developer>
<name>DmitriyMX</name>
<email>dmiriymx@yandex.ru</email>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
@@ -45,7 +54,6 @@
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
</dependencies>
<build>
@@ -70,13 +78,16 @@
</configuration>
</plugin>
<!-- Fat jar -->
<!-- mvn assebly:single -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<finalName>${project.artifactId}-${project.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<mainClass>ru.dmitriymx.Main</mainClass>
<mainClass>ru.dmitriymx.corrector1s.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
@@ -86,5 +97,4 @@
</plugin>
</plugins>
</build>
</project>

View File

@@ -1,6 +1,7 @@
package ru.dmitriymx.corrector1s;
import lombok.extern.slf4j.Slf4j;
import ru.dmitriymx.corrector1s.gui.MainApp;
import java.io.File;
import java.util.List;
@@ -8,6 +9,9 @@ import java.util.List;
@Slf4j
public class Main {
public static void main(String[] args) throws Exception {
if (args.length == 0) {
MainApp.main(args);
} else {
File file = new File(args[0]);
File file1 = new File(args[1]);
@@ -18,4 +22,5 @@ public class Main {
excelReader.insertNewCols();
excelReader.save(file1);
}
}
}

View File

@@ -0,0 +1,33 @@
package ru.dmitriymx.corrector1s.gui;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import java.io.IOException;
public class MainApp extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("1С корректор (v1.0)");
primaryStage.setResizable(false);
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("excel.png")));
primaryStage.setScene(loadScene(primaryStage));
primaryStage.show();
}
private Scene loadScene(Stage stage) throws IOException {
FXMLLoader loader = new FXMLLoader(getClass().getResource("single_layout.fxml"));
Scene scene = new Scene(loader.load(), 350-10, 203-10);
MainController controller = loader.getController();
controller.setStage(stage);
return scene;
}
}

View File

@@ -0,0 +1,107 @@
package ru.dmitriymx.corrector1s.gui;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.layout.Pane;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class MainController {
private Stage stage;
@FXML
private TextField sourceFilePath;
@FXML
private TextField saveAsFilePath;
@FXML
private CheckBox saveAsCheckBox;
@FXML
private Button btnSourceFilePath;
@FXML
private Button btnSaveAsFilePath;
@FXML
private Pane mainPane;
@FXML
private Pane waitPane;
@FXML
private ProgressIndicator progressBar;
@FXML
private Button btnStartCorrect;
@FXML
private Spinner<Integer> gonorar;
private SpinnerValueFactory<Integer> gonorarValueFactory = new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 100, 9);
private FileChooser buildFileChooser(TextField textField) {
FileChooser fileChooser = new FileChooser();
if (!textField.getText().isEmpty() && Files.exists(Paths.get(textField.getText()))) {
File file = new File(textField.getText());
if (file.isDirectory()) {
fileChooser.setInitialDirectory(file);
} else {
fileChooser.setInitialDirectory(file.getParentFile());
}
}
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(
"Таблицы Excel (*.xls, *.xlsx)",
"*.xls", "*.xlsx"));
return fileChooser;
}
@FXML
public void initialize() {
gonorar.setValueFactory(gonorarValueFactory);
saveAsCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
saveAsFilePath.setDisable(!newValue);
btnSaveAsFilePath.setDisable(!newValue);
});
btnSourceFilePath.addEventHandler(ActionEvent.ACTION, event -> {
File file = buildFileChooser(sourceFilePath).showOpenDialog(stage);
if (file != null) {
sourceFilePath.setText(file.getAbsolutePath());
if (!saveAsCheckBox.selectedProperty().get()) {
saveAsFilePath.setText(file.getAbsolutePath());
}
}
});
btnSaveAsFilePath.addEventHandler(ActionEvent.ACTION,
event -> buildFileChooser(saveAsFilePath).showSaveDialog(stage));
btnStartCorrect.addEventHandler(ActionEvent.ACTION, event -> {
mainPane.setDisable(true);
mainPane.setOpacity(0.3d);
waitPane.setVisible(true);
progressBar.setProgress(0d);
Runnable runnable = () -> {
do {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
break;
}
progressBar.setProgress(progressBar.getProgress() + 0.1d);
} while (progressBar.getProgress() <= 1.0d);
waitPane.setVisible(false);
mainPane.setOpacity(1.0d);
mainPane.setDisable(false);
};
Thread thread = new Thread(runnable);
thread.start();
});
}
void setStage(Stage stage) {
this.stage = stage;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ProgressIndicator?>
<?import javafx.scene.control.Spinner?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.text.Font?>
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="203.0" prefWidth="350.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ru.dmitriymx.corrector1s.gui.MainController">
<Pane fx:id="mainPane" prefHeight="203.0" prefWidth="350.0">
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
<ImageView fitHeight="103.0" fitWidth="108.0" pickOnBounds="true" preserveRatio="true" x="10.0" y="10.0">
<Image url="@excel.png" />
</ImageView>
<Label layoutX="132.0" layoutY="10.0" text="Исходный файл" />
<TextField fx:id="sourceFilePath" layoutX="132.0" layoutY="32.0" prefHeight="25.0" prefWidth="178.0" />
<Button fx:id="btnSourceFilePath" layoutX="313.0" layoutY="32.0" mnemonicParsing="false" text="..." />
<CheckBox fx:id="saveAsCheckBox" layoutX="132.0" layoutY="95.0" mnemonicParsing="false" text="Сохранить как..." />
<TextField fx:id="saveAsFilePath" disable="true" layoutX="131.0" layoutY="117.0" prefHeight="25.0" prefWidth="178.0" />
<Button fx:id="btnSaveAsFilePath" disable="true" layoutX="312.0" layoutY="117.0" mnemonicParsing="false" text="..." />
<Button fx:id="btnStartCorrect" layoutX="13.0" layoutY="162.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="324.0" text="Преобразовать">
<font>
<Font name="System Bold" size="12.0" />
</font>
</Button>
<Label layoutX="132.0" layoutY="66.0" text="Гонорар" />
<Spinner fx:id="gonorar" editable="true" layoutX="186.0" layoutY="62.0" prefHeight="25.0" prefWidth="77.0" />
</Pane>
<Pane fx:id="waitPane" prefHeight="203.0" prefWidth="350.0" visible="false">
<ProgressIndicator fx:id="progressBar" layoutX="157.0" layoutY="62.0" prefHeight="50.0" prefWidth="36.0" progress="1.0" />
</Pane>
</Pane>