Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Open With apps for macOS #917

Merged
merged 17 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
b73fd4e
macos - open with macos: tabs to spaces, code style, removed unused code
pskowronek Apr 30, 2023
f22a6ca
Added Open With apps for macOS #759
pskowronek May 2, 2023
877a6ce
Added Open With apps for macOS - better logging of error
pskowronek May 2, 2023
6ea40b9
Open With apps for macOS - better duti cmd handling and caching
pskowronek May 4, 2023
d98ee47
Preferences for Open With apps for macOS - tabs to spaces
pskowronek May 4, 2023
01f4cc7
Preferences for Open With apps for macOS
pskowronek May 4, 2023
be8746d
Preferences for Open With apps for macOS - removed unused import
pskowronek May 4, 2023
94ec01d
Preferences for Open With apps for macOS - app cache case-insensitive
pskowronek May 6, 2023
8818d8f
Open With apps for macOS - reverted Prefs changes and added menu hint…
pskowronek May 6, 2023
cb7c63e
Open With apps for macOS - small fix to remove ... from menu item
pskowronek May 6, 2023
465d82b
Open With apps for macOS - small fix for animated icon
pskowronek May 7, 2023
9414c2c
Open With apps for macOS - more caching (size limited)
pskowronek May 7, 2023
1fd49dc
Open With apps for macOS - better caching (size limited)
pskowronek May 8, 2023
e29a108
Open With apps for macOS - fixes after PR review
pskowronek May 13, 2023
ecacbd7
Open With apps for macOS - fixes after PR review cont'd
pskowronek May 13, 2023
786c959
Open With apps for macOS - fixes after PR review - switch format
pskowronek May 13, 2023
ced6ee9
Added Open With apps for macOS - addressed PR review
pskowronek May 14, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ public void startAssociation(String command) {
public void endAssociation() throws CommandException {
// Skip empty file filters as they will break the whole
// association mechanism.
if(!filter.isEmpty())
if (!filter.isEmpty()) {
CommandManager.registerAssociation(command, filter);
}
}

public void setMask(String mask, boolean isCaseSensitive) {filter.addFileFilter(new RegexpFilenameFilter(mask, isCaseSensitive));}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import java.util.List;
import java.util.Vector;

import javax.swing.Icon;

/**
* Compiled shell commands.
* <p>
Expand Down Expand Up @@ -101,62 +103,75 @@ public class Command implements Comparable<Command> {
private final String displayName;
/** Command type. */
private final CommandType type;


/** Icon associated with command */
private final Icon icon;

// - Initialisation ------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------
/**
* Creates a new command.
* @param alias alias of the command.
* @param command command that will be executed.
* @param command command that will be executed.
* @param type type of the command.
* @param displayName name of the command as seen by users (if <code>null</code>, defaults to <code>alias</code>).
* @param icon icon to be associated with this command, can be null.
*/
public Command(String alias, String command, CommandType type, String displayName) {
public Command(String alias, String command, CommandType type, String displayName, Icon icon) {
this.alias = alias;
this.type = type;
this.displayName = displayName;
this.command = command;
this.icon = icon;
}

// - Initialisation ------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------
/**
* Creates a new command.
* @param alias alias of the command.
* @param command command that will be executed.
* @param type type of the command.
* @param displayName name of the command as seen by users (if <code>null</code>, defaults to <code>alias</code>).
*/
public Command(String alias, String command, CommandType type, String displayName) {
this(alias, command, type, displayName, null);
}

/**
* Creates a new command.
* <p>
* This is a convenience constructor and is strictly equivalent to calling
* <code>{@link #Command(String,String,int,String) Command(}alias, command, {@link #NORMAL_COMMAND}, null)</code>.
* <code>{@link #Command(String,String,int,String,Icon) Command(}alias, command, {@link #NORMAL_COMMAND}, null, null)</code>.
* </p>
* @param alias alias of the command.
* @param command command that will be executed.
*/
public Command(String alias, String command) {
this(alias, command, CommandType.NORMAL_COMMAND, null);
this(alias, command, CommandType.NORMAL_COMMAND, null, null);
}

/**
* Creates a new command.
* <p>
* This is a convenience constructor and is strictly equivalent to calling
* <code>{@link #Command(String,String,int,String) Command(}alias, command, type, null)</code>.
* <code>{@link #Command(String,String,int,String,Icon) Command(}alias, command, type, null, null)</code>.
* </p>
* @param alias alias of the command.
* @param command command that will be executed.
* @param type type of the command.
*/
public Command(String alias, String command, CommandType type) {
this(alias, command, type, null);
this(alias, command, type, null);
}



// - Token retrieval -----------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------
/**
* Returns this command's tokens without performing keyword substitution.
* @return this command's tokens without performing keyword substitution.
*/
public synchronized String[] getTokens() {
return getTokens(command, (AbstractFile[])null);
return getTokens(command, (AbstractFile[])null);
}

/**
Expand All @@ -165,7 +180,7 @@ public synchronized String[] getTokens() {
* @return this command's tokens, replacing keywords by the corresponding values from the specified file.
*/
public synchronized String[] getTokens(AbstractFile file) {
return getTokens(command, file);
return getTokens(command, file);
}

/**
Expand All @@ -174,7 +189,7 @@ public synchronized String[] getTokens(AbstractFile file) {
* @return this command's tokens, replacing keywords by the corresponding values from the specified fileset.
*/
public synchronized String[] getTokens(FileSet files) {
return getTokens(command, files);
return getTokens(command, files);
}

/**
Expand All @@ -183,7 +198,7 @@ public synchronized String[] getTokens(FileSet files) {
* @return this command's tokens, replacing keywords by the corresponding values from the specified files.
*/
public synchronized String[] getTokens(AbstractFile[] files) {
return getTokens(command, files);
return getTokens(command, files);
}

/**
Expand All @@ -202,7 +217,7 @@ public static String[] getTokens(String command) {
* @return the specified command's tokens after replacing keywords by the corresponding values from the specified file.
*/
public String[] getTokens(String command, AbstractFile file) {
return getTokens(command, new AbstractFile[] {file});
return getTokens(command, new AbstractFile[] {file});
}

/**
Expand All @@ -212,7 +227,7 @@ public String[] getTokens(String command, AbstractFile file) {
* @return the specified command's tokens after replacing keywords by the corresponding values from the specified fileset.
*/
public String[] getTokens(String command, FileSet files) {
return getTokens(command, files.toArray(new AbstractFile[files.size()]));
return getTokens(command, files.toArray(new AbstractFile[files.size()]));
}

/**
Expand Down Expand Up @@ -330,7 +345,7 @@ else if(j != files.length - 1)
* @return whether this command contains keywords referencing selected file.
*/
public synchronized boolean hasSelectedFileKeyword() {
String[] tokens = getTokens();
String[] tokens = getTokens();
for (String token : tokens) {
// Not using regexp because it depends on the definition of KEYWORD_*
if (token.startsWith("" + KEYWORD_HEADER + KEYWORD_PATH)
Expand Down Expand Up @@ -427,23 +442,23 @@ public int compareTo(Command command) {
* @return the original, un-tokenised command.
*/
public synchronized String getCommand() {
return command;
return command;
}

/**
* Returns this command's alias.
* @return this command's alias.
*/
public synchronized String getAlias() {
return alias;
return alias;
}

/**
* Returns the command's type.
* @return the command's type.
*/
public synchronized CommandType getType() {
return type;
return type;
}

/**
Expand All @@ -454,19 +469,27 @@ public synchronized CommandType getType() {
* @return the command's display name.
*/
public synchronized String getDisplayName() {
return displayName != null ? displayName : alias;
return displayName != null ? displayName : alias;
}

/**
* Returns <code>true</code> if the command's display name has been set.
* @return <code>true</code> if the command's display name has been set, <code>false</code> otherwise.
*/
synchronized boolean isDisplayNameSet() {
return displayName != null;
return displayName != null;
}

/**
* Returns an icon associated with this command.
* @return an icon, or null;
*/
public Icon getIcon() {
return icon;
}

@Override
public String toString() {
return alias + (displayName == null ? "" : ":" + displayName) + ":" + command;
return alias + (displayName == null ? "" : ":" + displayName) + ":" + command;
}
}
Loading