Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .run/Run App.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run App" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" singleton="false">
<option name="ACTIVE_PROFILES" />
<option name="ALTERNATIVE_JRE_PATH" value="/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<module name="drrename" />
<selectedOptions>
<option name="environmentVariables" />
</selectedOptions>
<option name="SPRING_BOOT_MAIN_CLASS" value="drrename.Launcher" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
12 changes: 12 additions & 0 deletions .run/Run all tests.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run all tests" type="JUnit" factoryName="JUnit">
<module name="drrename" />
<option name="PACKAGE_NAME" value="" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
37 changes: 37 additions & 0 deletions src/main/java/drrename/Beans.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,18 @@

package drrename;

import drrename.ui.ResourceBundleAwareLazyFxControllerAndViewResolver;
import drrename.ui.config.UiConfig;
import javafx.scene.Node;
import lombok.extern.slf4j.Slf4j;
import net.rgielen.fxweaver.core.FxControllerAndView;
import net.rgielen.fxweaver.core.FxWeaver;
import net.rgielen.fxweaver.spring.SpringFxWeaver;
import org.springframework.beans.factory.InjectionPoint;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.Locale;
Expand All @@ -37,6 +46,34 @@ public Beans(UiConfig config) {
this.config = config;
}

@Bean
public FxWeaver fxWeaver(ConfigurableApplicationContext applicationContext) {
// Would also work with javafx-weaver-core only:
// return new FxWeaver(applicationContext::getBean, applicationContext::close);
return new SpringFxWeaver(applicationContext);
}

@Bean
public Settings settings(SettingsProvider settingsProvider){
var settings = settingsProvider.load();
log.debug("Instantiated settings {}", settings);
return settings;
}

/**
* See {@link net.rgielen.fxweaver.samples.springboot.controller.DialogController#DialogController(FxControllerAndView)}
* for an example usage.
* <p/>
* <strong>MUST be in scope prototype!</strong>
*/
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public <C, V extends Node> FxControllerAndView<C, V> controllerAndView(FxWeaver fxWeaver,
InjectionPoint injectionPoint, ResourceBundle bundle) {
return new ResourceBundleAwareLazyFxControllerAndViewResolver(fxWeaver, bundle)
.resolve(injectionPoint);
}

@Bean
public ResourceBundle bundle() {
Locale locale = Locale.getDefault();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
package drrename.service;
/*
* Dr.Rename - A Minimalistic Batch Renamer
*
* Copyright (C) 2022
*
* This file is part of Dr.Rename.
*
* You can redistribute it and/or modify it under the terms of the GNU Affero
* General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
* for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package drrename;

import drrename.config.AppConfig;
import drrename.event.FileRenamedEvent;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/drrename/GeneralExceptionHandler.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package drrename;

import drrename.util.ArrayUtil;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.TextArea;
Expand Down Expand Up @@ -27,7 +28,7 @@ private void showAlertDialog(Throwable e) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle(String.format(resourceBundle.getString(ALERT_TITLE)));
alert.setHeaderText(e.getLocalizedMessage());
TextArea area = new TextArea(Util.stackTraceToString(e));
TextArea area = new TextArea(ArrayUtil.stackTraceToString(e));
alert.getDialogPane().setContent(area);
area.setWrapText(true);
area.setEditable(false);
Expand Down
40 changes: 0 additions & 40 deletions src/main/java/drrename/Launcher.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
package drrename;

import drrename.ui.ResourceBundleAwareLazyFxControllerAndViewResolver;
import javafx.scene.Node;
import lombok.extern.slf4j.Slf4j;
import net.rgielen.fxweaver.core.FxControllerAndView;
import net.rgielen.fxweaver.core.FxWeaver;
import net.rgielen.fxweaver.spring.SpringFxWeaver;
import org.springframework.beans.factory.InjectionPoint;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;

import java.util.ResourceBundle;

@Slf4j
@EnableFeignClients
Expand All @@ -24,32 +12,4 @@ public class Launcher {
public static void main(String[] args) {
DrRenameApplication.main(args);
}

@Bean
public FxWeaver fxWeaver(ConfigurableApplicationContext applicationContext) {
// Would also work with javafx-weaver-core only:
// return new FxWeaver(applicationContext::getBean, applicationContext::close);
return new SpringFxWeaver(applicationContext);
}

@Bean
public Settings settings(SettingsProvider settingsProvider){
var settings = settingsProvider.load();
log.debug("Instantiated settings {}", settings);
return settings;
}

/**
* See {@link net.rgielen.fxweaver.samples.springboot.controller.DialogController#DialogController(FxControllerAndView)}
* for an example usage.
* <p/>
* <strong>MUST be in scope prototype!</strong>
*/
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public <C, V extends Node> FxControllerAndView<C, V> controllerAndView(FxWeaver fxWeaver,
InjectionPoint injectionPoint, ResourceBundle bundle) {
return new ResourceBundleAwareLazyFxControllerAndViewResolver(fxWeaver, bundle)
.resolve(injectionPoint);
}
}
34 changes: 0 additions & 34 deletions src/main/java/drrename/MovieDbClientConfig.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
import drrename.event.DummyFileCreatorButtonGoEvent;
import drrename.ui.mainview.GoCancelButtonsComponentController;
import drrename.ui.mainview.StartDirectoryComponentController;
import drrename.ui.mainview.controller.TabController;
import javafx.event.ActionEvent;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.TextField;
Expand All @@ -48,7 +51,7 @@
@FxmlView("/fxml/DummyFileCreator.fxml")
public class DummyFileCreatorController implements Initializable {

public StartDirectoryComponentController startDirectoryComponentController;
private final TabController tabController;

public GoCancelButtonsComponentController goCancelButtonsComponentController;

Expand All @@ -58,7 +61,7 @@ public class DummyFileCreatorController implements Initializable {

public ProgressBar progressBar;

public BorderPane root;
public Parent root;

private final FileCreatorService fileCreatorService;

Expand All @@ -73,14 +76,12 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
TextFormatter<Number> textFormatter = new TextFormatter<>(new NumberStringConverter());
wordSeparator.setText("_");
filesCnt.setTextFormatter(textFormatter);
goCancelButtonsComponentController.buttonGo.disableProperty().bind(fileCreatorService.runningProperty().or(startDirectoryComponentController.readyProperty().not().or(filesCnt.textProperty().isEmpty())));
goCancelButtonsComponentController.buttonGo.disableProperty().bind(fileCreatorService.runningProperty().or(tabController.startDirectoryComponentController.readyProperty().not().or(filesCnt.textProperty().isEmpty())));
goCancelButtonsComponentController.buttonCancel.disableProperty().bind(fileCreatorService.runningProperty().not());
goCancelButtonsComponentController.setButtonCancelActionEventFactory( DummyFileCreatorButtonCancelEvent::new);
goCancelButtonsComponentController.setButtonGoActionEventFactory(DummyFileCreatorButtonGoEvent::new);
progressBar.visibleProperty().bind(fileCreatorService.runningProperty());

log.debug("Input component: {}", startDirectoryComponentController);
log.debug("Buttons component: {}", goCancelButtonsComponentController);
}

public void show() {
Expand Down Expand Up @@ -110,7 +111,7 @@ private void startService() {
fileCreatorService.cancel();
fileCreatorService.reset();
fileCreatorService.setFileCnt((long) filesCnt.getTextFormatter().getValue());
fileCreatorService.setDirectory(startDirectoryComponentController.getInputPath());
fileCreatorService.setDirectory(tabController.startDirectoryComponentController.getInputPath());
fileCreatorService.setWordSeparator(wordSeparator.getText());
progressBar.progressProperty().bind(fileCreatorService.progressProperty());
fileCreatorService.start();
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/drrename/kodi/KodiToolsController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package drrename.kodi;

import drrename.ui.FXUtil;
import drrename.kodi.treeitem.FilterableKodiRootTreeItem;
import drrename.kodi.treeitem.KodiTreeItemValue;
import drrename.ui.mainview.controller.TabController;
import drrename.util.FXUtil;
import drrename.ui.mainview.GoCancelButtonsComponentController;
import drrename.ui.mainview.StartDirectoryComponentController;
import javafx.application.Platform;
Expand Down Expand Up @@ -40,6 +43,8 @@ public class KodiToolsController implements Initializable {

public static final int imageStageXOffset = 600;

private final TabController tabController;

public BorderPane root;

public ProgressBar progressBar;
Expand All @@ -60,8 +65,6 @@ public class KodiToolsController implements Initializable {

Stage imageStage;

public StartDirectoryComponentController startDirectoryComponentController;

public GoCancelButtonsComponentController goCancelButtonsComponentController;

private final MovieDirectoryCollectorService service;
Expand All @@ -80,7 +83,7 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
imageStage = new Stage();
mainStage.setScene(new Scene(root));
mainStage.setTitle("Kodi Tools");
goCancelButtonsComponentController.buttonGo.disableProperty().bind(service.runningProperty().or(startDirectoryComponentController.readyProperty().not()));
goCancelButtonsComponentController.buttonGo.disableProperty().bind(service.runningProperty().or(tabController.startDirectoryComponentController.readyProperty().not()));
goCancelButtonsComponentController.buttonCancel.disableProperty().bind(service.runningProperty().not());
goCancelButtonsComponentController.setButtonCancelActionEventFactory(KodiToolsButtonCancelEvent::new);
goCancelButtonsComponentController.setButtonGoActionEventFactory(KodiToolsButtonGoEvent::new);
Expand All @@ -95,7 +98,7 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
buttonCollapseAll.setDisable(e.getList().isEmpty());
});
treeRoot.setPredicate(buildHideEmptyPredicate());
startDirectoryComponentController.inputPathProperty().addListener((observable, oldValue, newValue) -> {
tabController.startDirectoryComponentController.inputPathProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
onButtonGoEvent(null);
}
Expand Down Expand Up @@ -181,14 +184,14 @@ public void onButtonCancelEvent(KodiToolsButtonCancelEvent event){
}

private void startService() {
if (startDirectoryComponentController.getInputPath() == null) {
if (tabController.startDirectoryComponentController.getInputPath() == null) {
log.warn("Cannot start, input path is null");
return;
}
log.debug("Starting service {}", service);
service.reset();
treeRoot.getSourceChildren().clear();
service.setDirectory(startDirectoryComponentController.getInputPath());
service.setDirectory(tabController.startDirectoryComponentController.getInputPath());
service.setExecutor(executor);
service.setRootTreeItem(treeRoot);
service.setMovieDbClientFactory(movieDbClientFactory);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/drrename/kodi/KodiTreeCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package drrename.kodi;

import drrename.kodi.treeitem.KodiTreeItemValue;
import javafx.beans.binding.Bindings;
import javafx.scene.control.Control;
import javafx.scene.control.TreeCell;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/drrename/kodi/MediaFileNameChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public MediaFileNameCheckResult checkStatus(Path directory) {
List<Path> mediaFiles = findAllMediaFiles(directory);
for(Path mediaFile : mediaFiles){
String baseName = FilenameUtils.getBaseName(mediaFile.getFileName().toString());
if(baseName.startsWith(movieName)){
return new MediaFileNameCheckResult(MovieFileNameType.MATCHES_DIR_NAME, mediaFiles);
if(!baseName.equals(movieName)){
return new MediaFileNameCheckResult(MovieFileNameType.INVALID_MEDIA_FILE_NAME, mediaFiles);
}
}
if(!mediaFiles.isEmpty()){
return new MediaFileNameCheckResult(MovieFileNameType.INVALID_MEDIA_FILE_NAME, mediaFiles);
return new MediaFileNameCheckResult(MovieFileNameType.MATCHES_DIR_NAME, mediaFiles);
}
} catch (IOException e) {
log.error(e.getLocalizedMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
*
* Copyright (C) 2022
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
* This file is part of Dr.Rename.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* You can redistribute it and/or modify it under the terms of the GNU Affero
* General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
* for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package drrename;
package drrename.kodi;

import drrename.model.themoviedb.SearchResultsDto;
import drrename.model.themoviedb.TranslationsDto;
Expand Down
Loading