mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 00:08:51 -05:00
Enable workflow service menu
This commit is contained in:
parent
538378a9b0
commit
7dd7908435
@ -16,8 +16,6 @@ link.app.purchase: @{link.app.purchase}
|
|||||||
|
|
||||||
link.intro: @{link.intro}
|
link.intro: @{link.intro}
|
||||||
link.forums: @{link.forums}
|
link.forums: @{link.forums}
|
||||||
link.twitter: @{link.twitter}
|
|
||||||
link.facebook: @{link.facebook}
|
|
||||||
link.faq: @{link.faq}
|
link.faq: @{link.faq}
|
||||||
link.bugs: @{link.bugs}
|
link.bugs: @{link.bugs}
|
||||||
link.channel: @{link.channel}
|
link.channel: @{link.channel}
|
||||||
|
@ -14,6 +14,7 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import javax.swing.JMenu;
|
||||||
import javax.swing.JMenuBar;
|
import javax.swing.JMenuBar;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
@ -109,6 +110,29 @@ public class MacAppUtilities {
|
|||||||
openFileHandler.accept(files);
|
openFileHandler.accept(files);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// add workflow service menu
|
||||||
|
initializeWorkflowServiceMenu(appMenuBar.getMenu(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void initializeWorkflowServiceMenu(JMenu menu) {
|
||||||
|
String root = System.getProperty("apple.app.workflows");
|
||||||
|
String home = System.getProperty("user.home");
|
||||||
|
|
||||||
|
if (root == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
menu.addSeparator();
|
||||||
|
|
||||||
|
for (WorkflowType type : WorkflowType.values()) {
|
||||||
|
File templateFolder = new File(root, type.getFolderName());
|
||||||
|
File targetFolder = new File(home, type.getLibraryPath());
|
||||||
|
|
||||||
|
if (templateFolder.exists()) {
|
||||||
|
menu.add(new WorkflowMenu(type.getFolderName(), templateFolder, targetFolder));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLockedFolder(File folder) {
|
public static boolean isLockedFolder(File folder) {
|
||||||
|
@ -29,19 +29,17 @@ public class WorkflowMenu extends DynamicMenu {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void populate() {
|
protected void populate() {
|
||||||
for (File workflow : templateFolder.listFiles(WORKFLOW)) {
|
for (File template : templateFolder.listFiles(WORKFLOW)) {
|
||||||
if (isInstalled(workflow)) {
|
File target = new File(targetFolder, template.getName());
|
||||||
add(createUninstallMenu(workflow));
|
|
||||||
|
if (target.exists()) {
|
||||||
|
add(createUninstallMenu(target));
|
||||||
} else {
|
} else {
|
||||||
add(createInstallMenu(workflow));
|
add(createInstallMenu(template));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isInstalled(File workflow) {
|
|
||||||
return new File(targetFolder, workflow.getName()).exists();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected JMenuItem createInstallMenu(File workflow) {
|
protected JMenuItem createInstallMenu(File workflow) {
|
||||||
JMenu menu = new JMenu(getNameWithoutExtension(workflow.getName()));
|
JMenu menu = new JMenu(getNameWithoutExtension(workflow.getName()));
|
||||||
|
|
||||||
|
25
source/net/filebot/platform/mac/WorkflowType.java
Normal file
25
source/net/filebot/platform/mac/WorkflowType.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package net.filebot.platform.mac;
|
||||||
|
|
||||||
|
public enum WorkflowType {
|
||||||
|
|
||||||
|
QuickAction, FolderAction;
|
||||||
|
|
||||||
|
public String getFolderName() {
|
||||||
|
switch (this) {
|
||||||
|
case QuickAction:
|
||||||
|
return "Quick Actions";
|
||||||
|
default:
|
||||||
|
return "Folder Actions";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLibraryPath() {
|
||||||
|
switch (this) {
|
||||||
|
case QuickAction:
|
||||||
|
return "Library/Services";
|
||||||
|
default:
|
||||||
|
return "Library/Workflows/Applications/Folder Actions";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user