1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-23 00:08:51 -05:00

Experiment with user prompts

This commit is contained in:
Reinhard Pointner 2018-06-15 03:00:11 +07:00
parent 803fb7b083
commit cf5275bfdb

View File

@ -87,6 +87,7 @@ class RenameAction extends AbstractAction {
Map<File, File> renameLog = new LinkedHashMap<File, File>(); Map<File, File> renameLog = new LinkedHashMap<File, File>();
try { try {
// require valid license for rename mode
LICENSE.check(); LICENSE.check();
if (useNativeShell() && NativeRenameAction.isSupported(action)) { if (useNativeShell() && NativeRenameAction.isSupported(action)) {
@ -100,9 +101,12 @@ class RenameAction extends AbstractAction {
ProgressMonitor.runTask(action.getDisplayName(), message, worker).get(); ProgressMonitor.runTask(action.getDisplayName(), message, worker).get();
} }
} catch (LicenseError e) { } catch (LicenseError e) {
JComponent source = (JComponent) evt.getSource(); if (LICENSE.isFile()) {
createLicensePopup(e.getMessage(), evt).show(source, -3, source.getHeight() + 4); JComponent source = (JComponent) evt.getSource();
return; createLicensePopup(e.getMessage(), evt).show(source, -3, source.getHeight() + 4);
} else {
log.severe(e::getMessage);
}
} catch (CancellationException e) { } catch (CancellationException e) {
debug.finest(e::toString); debug.finest(e::toString);
} catch (Throwable e) { } catch (Throwable e) {
@ -232,12 +236,12 @@ class RenameAction extends AbstractAction {
return emptyMap(); return emptyMap();
} }
private ActionPopup createLicensePopup(String message, ActionEvent parent) { private ActionPopup createLicensePopup(String message, ActionEvent evt) {
ActionPopup actionPopup = new ActionPopup("License Required", ResourceManager.getIcon("file.lock")); ActionPopup actionPopup = new ActionPopup("License Required", ResourceManager.getIcon("file.lock"));
actionPopup.add(newAction("Select License", ResourceManager.getIcon("license.import"), e -> { actionPopup.add(newAction("Select License", ResourceManager.getIcon("license.import"), e -> {
withWaitCursor(parent.getSource(), () -> { withWaitCursor(evt.getSource(), () -> {
List<File> files = UserFiles.FileChooser.AWT.showLoadDialogSelectFiles(false, false, null, MediaTypes.LICENSE_FILES, "Select License", parent); List<File> files = UserFiles.FileChooser.AWT.showLoadDialogSelectFiles(false, false, null, MediaTypes.LICENSE_FILES, "Select License", evt);
if (files.size() > 0) { if (files.size() > 0) {
configureLicense(files.get(0)); configureLicense(files.get(0));
SwingEventBus.getInstance().post(LICENSE); SwingEventBus.getInstance().post(LICENSE);