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

new options select shell and file manager #86

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fixed line endings
  • Loading branch information
Javatlacati authored and Javatlacati committed Nov 11, 2017
commit e689885582a6231a3777ecc6b316e62614c0eed9
74 changes: 37 additions & 37 deletions QuickOpener/src/main/java/me/dsnet/quickopener/QuickMessages.java
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package me.dsnet.quickopener;

/**
*
* @author SessonaD
*/
public enum QuickMessages {

NO_FILE_IN_SELECTION ("There are no files associated with the current selection."),
CONFIRM_COMMAND_PREFIX ("You are about to launch the following command:\n\n"),
CONFIRM_COMMAND_SUFFIX ("\n\nAre you sure?"),
DESCRIPTION_MANDATORY ("A description is mandatory."),
FOLDER_INVALID ("The folder specified is not valid or does not exists."),
FOLDER_ADDED ("Folder added as favorite."),
SEPARATOR_NULL ("Separator cannot be empty."),
CUSTOM_SHELL ("Custom shell cannot be empty."),
NO_COMMAND ("No command given."),
NO_DEFAULT_PARAMETERS ("Some placeholders could not be replaced."),
DEFAULT_COMMAND_PARAMETERS ("A default command cannot contain parameters."),
NOT_IN_FILE_SYSTEM ("The file does not exists in the file system.");

private String message;

private QuickMessages(String message) {
this.message = message;
}

@Override
public String toString() {
return message ;
}

}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package me.dsnet.quickopener;
/**
*
* @author SessonaD
*/
public enum QuickMessages {
NO_FILE_IN_SELECTION ("There are no files associated with the current selection."),
CONFIRM_COMMAND_PREFIX ("You are about to launch the following command:\n\n"),
CONFIRM_COMMAND_SUFFIX ("\n\nAre you sure?"),
DESCRIPTION_MANDATORY ("A description is mandatory."),
FOLDER_INVALID ("The folder specified is not valid or does not exists."),
FOLDER_ADDED ("Folder added as favorite."),
SEPARATOR_NULL ("Separator cannot be empty."),
CUSTOM_SHELL ("Custom shell cannot be empty."),
NO_COMMAND ("No command given."),
NO_DEFAULT_PARAMETERS ("Some placeholders could not be replaced."),
DEFAULT_COMMAND_PARAMETERS ("A default command cannot contain parameters."),
NOT_IN_FILE_SYSTEM ("The file does not exists in the file system.");
private String message;
private QuickMessages(String message) {
this.message = message;
}
@Override
public String toString() {
return message ;
}
}
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
package me.dsnet.quickopener.actions;

import java.io.File;
import me.dsnet.quickopener.PathFinder;
import org.openide.loaders.DataObject;
import org.openide.nodes.Node;
import org.openide.util.HelpCtx;
import org.openide.util.actions.NodeAction;

public abstract class AbstractFileContextAwareAction extends NodeAction {

private File file;

protected File getFile() {
return file;
}

@Override
protected boolean asynchronous() {
return false;
}

@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}

@Override
public abstract String getName();

@Override
protected boolean enable(Node[] activatedNodes) {
file = null;
if (null != activatedNodes && activatedNodes.length == 1) {

file = PathFinder.getActiveFile(activatedNodes[0].getLookup().lookup(DataObject.class), false);
}
return null != file;
}

@Override
protected abstract String iconResource();

@Override
protected abstract void performAction(Node[] activatedNodes);

}
package me.dsnet.quickopener.actions;
import java.io.File;
import me.dsnet.quickopener.PathFinder;
import org.openide.loaders.DataObject;
import org.openide.nodes.Node;
import org.openide.util.HelpCtx;
import org.openide.util.actions.NodeAction;
public abstract class AbstractFileContextAwareAction extends NodeAction {
private File file;
protected File getFile() {
return file;
}
@Override
protected boolean asynchronous() {
return false;
}
@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}
@Override
public abstract String getName();
@Override
protected boolean enable(Node[] activatedNodes) {
file = null;
if (null != activatedNodes && activatedNodes.length == 1) {
file = PathFinder.getActiveFile(activatedNodes[0].getLookup().lookup(DataObject.class), false);
}
return null != file;
}
@Override
protected abstract String iconResource();
@Override
protected abstract void performAction(Node[] activatedNodes);
}
114 changes: 57 additions & 57 deletions QuickOpener/src/main/java/me/dsnet/quickopener/actions/FileSystem.java
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
package me.dsnet.quickopener.actions;

import com.sessonad.oscommands.commands.Commands;
import me.dsnet.quickopener.QuickMessages;
import java.io.File;
import org.netbeans.api.annotations.common.StaticResource;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.awt.ActionID;
import org.openide.awt.ActionRegistration;
import org.openide.nodes.Node;
import org.openide.util.NbBundle.Messages;

/**
*
* @author SessonaD
* @author markiewb (contributor)
*/
@ActionID(
category = "Tools",
id = "me.dsnet.quickopener.actions.FileSystem")
@ActionRegistration(
lazy = false,
displayName = "#CTL_FileSystem"
)
@Messages("CTL_FileSystem=Open in File Manager")
public final class FileSystem extends AbstractFileContextAwareAction {

@StaticResource
private static final String icon = "me/dsnet/quickopener/icons/folder-documents-icon.png";

@Override
public String getName() {
return Bundle.CTL_FileSystem();
}

@Override
protected String iconResource() {
return icon;
}

@Override
protected void performAction(Node[] activatedNodes) {
File file = getFile();

if (file == null) {
NotifyDescriptor d = new NotifyDescriptor.Message(QuickMessages.NO_FILE_IN_SELECTION, NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify(d);
return;
}
try {
Commands.getPlatform().browseInFileSystemToFileOrDir(file);
} catch (Exception ex) {
}//ex.printStackTrace();}
}

}
package me.dsnet.quickopener.actions;
import com.sessonad.oscommands.commands.Commands;
import me.dsnet.quickopener.QuickMessages;
import java.io.File;
import org.netbeans.api.annotations.common.StaticResource;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.awt.ActionID;
import org.openide.awt.ActionRegistration;
import org.openide.nodes.Node;
import org.openide.util.NbBundle.Messages;
/**
*
* @author SessonaD
* @author markiewb (contributor)
*/
@ActionID(
category = "Tools",
id = "me.dsnet.quickopener.actions.FileSystem")
@ActionRegistration(
lazy = false,
displayName = "#CTL_FileSystem"
)
@Messages("CTL_FileSystem=Open in File Manager")
public final class FileSystem extends AbstractFileContextAwareAction {
@StaticResource
private static final String icon = "me/dsnet/quickopener/icons/folder-documents-icon.png";
@Override
public String getName() {
return Bundle.CTL_FileSystem();
}
@Override
protected String iconResource() {
return icon;
}
@Override
protected void performAction(Node[] activatedNodes) {
File file = getFile();
if (file == null) {
NotifyDescriptor d = new NotifyDescriptor.Message(QuickMessages.NO_FILE_IN_SELECTION, NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify(d);
return;
}
try {
Commands.getPlatform().browseInFileSystemToFileOrDir(file);
} catch (Exception ex) {
}//ex.printStackTrace();}
}
}
Loading