本文整理汇总了Java中net.sf.memoranda.util.MimeTypesList.getMimeTypeForFile方法的典型用法代码示例。如果您正苦于以下问题:Java MimeTypesList.getMimeTypeForFile方法的具体用法?Java MimeTypesList.getMimeTypeForFile怎么用?Java MimeTypesList.getMimeTypeForFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.memoranda.util.MimeTypesList
的用法示例。
在下文中一共展示了MimeTypesList.getMimeTypeForFile方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runApp
import net.sf.memoranda.util.MimeTypesList; //导入方法依赖的package包/类
void runApp(String fpath) {
MimeType mt = MimeTypesList.getMimeTypeForFile(fpath);
if (mt.getMimeTypeId().equals("__UNKNOWN")) {
mt = addResourceType(fpath);
if (mt == null)
return;
}
if (!checkApp(mt))
return;
String[] command = MimeTypesList.getAppList().getCommand(mt.getAppId(), fpath);
if (command == null)
return;
/*DEBUG*/
System.out.println("Run: " + command[0]);
try {
Runtime.getRuntime().exec(command);
}
catch (Exception ex) {
new ExceptionDialog(ex, "Failed to run an external application <br><code>"
+command[0]+"</code>", "Check the application path and command line parameters for this resource type " +
"(File->Preferences->Resource types).");
}
}
示例2: runApp
import net.sf.memoranda.util.MimeTypesList; //导入方法依赖的package包/类
void runApp(String fpath) {
MimeType mt = MimeTypesList.getMimeTypeForFile(fpath);
if (mt.getMimeTypeId().equals("__UNKNOWN")) {
mt = addResourceType(fpath);
if (mt == null)
return;
}
if (!checkApp(mt))
return;
String[] command = MimeTypesList.getAppList().getCommand(mt.getAppId(), fpath);
if (command == null)
return;
/* DEBUG */
System.out.println("Run: " + command[0]);
try {
Runtime.getRuntime().exec(command);
} catch (Exception ex) {
new ExceptionDialog(ex, "Failed to run an external application <br><code>" + command[0] + "</code>",
"Check the application path and command line parameters for this resource type "
+ "(File->Preferences->Resource types).");
}
}
示例3: getValueAt
import net.sf.memoranda.util.MimeTypesList; //导入方法依赖的package包/类
public Object getValueAt(int row, int col) {
Resource r = (Resource)files.get(row);
if (col == _RESOURCE)
return r;
if (!r.isInetShortcut()) {
File f = new File(r.getPath());
switch (col) {
case 0: return f.getName();
case 1: MimeType mt = MimeTypesList.getMimeTypeForFile(f.getName());
if (mt != null) return mt.getLabel();
else return "unknown";
case 2: Date d = new Date(f.lastModified());
return d;/*Local.getDateString(d, java.text.DateFormat.SHORT) +" "+
Local.getTimeString(d);*/
case 3:return f.getPath();
}
}
else {
if (col == 0)
return r.getPath();
else if (col == 1)
return Local.getString("Internet shortcut");
else
return "";
}
return null;
}
示例4: runApp
import net.sf.memoranda.util.MimeTypesList; //导入方法依赖的package包/类
void runApp(String fpath) {
MimeType mt = MimeTypesList.getMimeTypeForFile(fpath);
if (mt.getMimeTypeId().equals("__UNKNOWN")) {
mt = addResourceType(fpath);
if (mt == null) {
return;
}
}
if (!checkApp(mt)) {
return;
}
String[] command = MimeTypesList.getAppList().getCommand(mt.getAppId(), fpath);
if (command == null) {
return;
}
/* DEBUG */
System.out.println("Run: " + command[0]);
try {
Runtime.getRuntime().exec(command);
} catch (Exception ex) {
new ExceptionDialog(ex, "Failed to run an external application <br><code>" + command[0] + "</code>",
"Check the application path and command line parameters for this resource type "
+ "(File->Preferences->Resource types).");
}
}
示例5: newResB_actionPerformed
import net.sf.memoranda.util.MimeTypesList; //导入方法依赖的package包/类
void newResB_actionPerformed(ActionEvent e) {
AddResourceDialog dlg = new AddResourceDialog(App.getFrame(), Local.getString("New resource"));
Dimension frmSize = App.getFrame().getSize();
Point loc = App.getFrame().getLocation();
dlg.setLocation((frmSize.width - dlg.getSize().width) / 2 + loc.x, (frmSize.height - dlg.getSize().height) / 2 + loc.y);
dlg.setVisible(true);
if (dlg.CANCELLED)
return;
if (dlg.localFileRB.isSelected()) {
String fpath = dlg.pathField.getText();
MimeType mt = MimeTypesList.getMimeTypeForFile(fpath);
if (mt.getMimeTypeId().equals("__UNKNOWN")) {
mt = addResourceType(fpath);
if (mt == null)
return;
}
if (!checkApp(mt))
return;
// if file if projectFile, than copy the file and change url.
if (dlg.projectFileCB.isSelected()) {
fpath = copyFileToProjectDir(fpath);
CurrentProject.getResourcesList().addResource(fpath, false, true);
}
else
CurrentProject.getResourcesList().addResource(fpath);
resourcesTable.tableChanged();
}
else {
if (!Util.checkBrowser())
return;
CurrentProject.getResourcesList().addResource(dlg.urlField.getText(), true, false);
resourcesTable.tableChanged();
}
}
示例6: getValueAt
import net.sf.memoranda.util.MimeTypesList; //导入方法依赖的package包/类
public Object getValueAt(int row, int col) {
Resource r = (Resource)files.get(row);
if (col == _RESOURCE)
return r;
if (!r.isInetShortcut()) {
File f = new File(r.getPath());
switch (col) {
case 0: return f.getName();
case 1: MimeType mt = MimeTypesList.getMimeTypeForFile(f.getName());
if (mt != null) return mt.getLabel();
else return "unknown";
case 2: Date d = new Date(f.lastModified());
return d;/*Local.getDateString(d, java.text.DateFormat.SHORT) +" "+
Local.getTimeString(d);*/
case 3:return f.getPath();
default:
break;
}
}
else {
if (col == 0)
return r.getPath();
else if (col == 1)
return Local.getString("Internet shortcut");
else
return "";
}
return null;
}
示例7: runApp
import net.sf.memoranda.util.MimeTypesList; //导入方法依赖的package包/类
/**
* Run the application associated with the file type.
* @param fpath
*/
void runApp(String fpath) {
try{
if (Desktop.isDesktopSupported()){
Desktop.getDesktop().open(new File(fpath));
}
else{
MimeType mt = MimeTypesList.getMimeTypeForFile(fpath);
if (mt.getMimeTypeId().equals("__UNKNOWN")) {
mt = addResourceType(fpath);
if (mt == null)
return;
}
if (!checkApp(mt))
return;
String[] command = MimeTypesList.getAppList().getCommand(mt.getAppId(), fpath);
if (command == null)
return;
Util.debug("Run: " + command[0]);
try {
Runtime.getRuntime().exec(command);
}
catch (Exception ex) {
new ExceptionDialog(ex, "Failed to run an external application <br><code>"
+command[0]+"</code>", "Check the application path and command line parameters for this resource type " +
"(File->Preferences->Resource types).");
}
}
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例8: getValueAt
import net.sf.memoranda.util.MimeTypesList; //导入方法依赖的package包/类
public Object getValueAt(int row, int col) {
Resource r = (Resource) files.get(row);
if (col == _RESOURCE)
return r;
if (!r.isInetShortcut()) {
File f = new File(r.getPath());
switch (col) {
case 0:
return f.getName();
case 1:
return r.getdescription();
case 2:
MimeType mt = MimeTypesList.getMimeTypeForFile(f.getName());
if (mt != null)
return mt.getLabel();
else
return "unknown";
case 3:
Date d = new Date(f.lastModified());
return d;/*
* Local.getDateString(d,
* java.text.DateFormat.SHORT) +" "+
* Local.getTimeString(d);
*/
case 4:
return f.getPath();
}
} else {
if (col == 0)
return r.getPath();
else if (col == 1)
return r.getdescription();
else if (col == 2)
return Local.getString("Internet shortcut");
else
return "";
}
return null;
}
示例9: newResB_actionPerformed
import net.sf.memoranda.util.MimeTypesList; //导入方法依赖的package包/类
void newResB_actionPerformed(ActionEvent e) {
AddResourceDialog dlg = new AddResourceDialog(App.getFrame(), Local.getString("New resource"));
Dimension frmSize = App.getFrame().getSize();
Point loc = App.getFrame().getLocation();
dlg.setLocation((frmSize.width - dlg.getSize().width) / 2 + loc.x,
(frmSize.height - dlg.getSize().height) / 2 + loc.y);
dlg.setVisible(true);
if (dlg.CANCELLED)
return;
if (dlg.localFileRB.isSelected()) {
String fpath = dlg.pathField.getText();
String description = dlg.descriptionField.getText();
MimeType mt = MimeTypesList.getMimeTypeForFile(fpath);
if (mt.getMimeTypeId().equals("__UNKNOWN")) {
mt = addResourceType(fpath);
if (mt == null)
return;
}
if (!checkApp(mt))
return;
// if file if projectFile, than copy the file and change url.
if (dlg.projectFileCB.isSelected()) {
fpath = copyFileToProjectDir(fpath);
CurrentProject.getResourcesList().addResource(fpath, description, false, true);
} else
CurrentProject.getResourcesList().addResource(fpath, description);
resourcesTable.tableChanged();
} else {
if (!Util.checkBrowser())
return;
CurrentProject.getResourcesList().addResource(dlg.urlField.getText(), dlg.descriptionField.getText(), true,
false);
resourcesTable.tableChanged();
}
}
示例10: getValueAt
import net.sf.memoranda.util.MimeTypesList; //导入方法依赖的package包/类
public Object getValueAt(int row, int col) {
Resource r = files.get(row);
if (col == _RESOURCE)
return r;
if (!r.isInetShortcut()) {
File f = new File(r.getPath());
switch (col) {
case 0:
return f.getName();
case 1:
MimeType mt = MimeTypesList.getMimeTypeForFile(f.getName());
return mt.getLabel();
case 2:
Date d = new Date(f.lastModified());
return d;
case 3:
return f.getPath();
}
} else {
if (col == 0)
return r.getPath();
else if (col == 1)
return Local.getString("Internet shortcut");
else
return "";
}
return null;
}
示例11: getValueAt
import net.sf.memoranda.util.MimeTypesList; //导入方法依赖的package包/类
@Override
public Object getValueAt(int row, int col) {
Resource r = (Resource) files.get(row);
if (col == _RESOURCE) {
return r;
}
if (!r.isInetShortcut()) {
File f = new File(r.getPath());
switch (col) {
case 0:
return f.getName();
case 1:
MimeType mt = MimeTypesList.getMimeTypeForFile(f.getName());
if (mt != null) {
return mt.getLabel();
} else {
return "unknown";
}
case 2:
Date d = new Date(f.lastModified());
return d;/*
* Local.getDateString(d,
* java.text.DateFormat.SHORT) +" "+
* Local.getTimeString(d);
*/
case 3:
return f.getPath();
}
} else {
if (col == 0) {
return r.getPath();
} else if (col == 1) {
return Local.getString("Internet shortcut");
} else {
return "";
}
}
return null;
}
示例12: newResB_actionPerformed
import net.sf.memoranda.util.MimeTypesList; //导入方法依赖的package包/类
void newResB_actionPerformed(ActionEvent e) {
AddResourceDialog dlg = new AddResourceDialog(App.getFrame(), Local.getString("New resource"));
Dimension frmSize = App.getFrame().getSize();
Point loc = App.getFrame().getLocation();
dlg.setLocation((frmSize.width - dlg.getSize().width) / 2 + loc.x,
(frmSize.height - dlg.getSize().height) / 2 + loc.y);
dlg.setVisible(true);
if (dlg.CANCELLED) {
return;
}
if (dlg.localFileRB.isSelected()) {
String fpath = dlg.pathField.getText();
MimeType mt = MimeTypesList.getMimeTypeForFile(fpath);
if (mt.getMimeTypeId().equals("__UNKNOWN")) {
mt = addResourceType(fpath);
if (mt == null) {
return;
}
}
if (!checkApp(mt)) {
return;
}
// if file if projectFile, than copy the file and change url.
if (dlg.projectFileCB.isSelected()) {
fpath = copyFileToProjectDir(fpath);
CurrentProject.getResourcesList().addResource(fpath, false, true);
} else {
CurrentProject.getResourcesList().addResource(fpath);
}
resourcesTable.tableChanged();
} else {
if (!Util.checkBrowser()) {
return;
}
CurrentProject.getResourcesList().addResource(dlg.urlField.getText(), true, false);
resourcesTable.tableChanged();
}
}
示例13: newResB_actionPerformed
import net.sf.memoranda.util.MimeTypesList; //导入方法依赖的package包/类
/**
* Connects new resource button to event.
* Creates new resource, adds to list, and adds to ResourcesTable which will update UI.
* @param e
*/
void newResB_actionPerformed(ActionEvent e) {
AddResourceDialog dlg = new AddResourceDialog(App.getFrame(), Local.getString("New resource"));
Dimension frmSize = App.getFrame().getSize();
Point loc = App.getFrame().getLocation();
dlg.setLocation((frmSize.width - dlg.getSize().width) / 2 + loc.x, (frmSize.height - dlg.getSize().height) / 2 + loc.y);
dlg.setVisible(true);
if (dlg.CANCELLED)
return;
if (dlg.localFileRB.isSelected()) {
String fpath = dlg.pathField.getText();
try{
//If the file runs add the file, if not have the user find the proper file.
if (Desktop.isDesktopSupported()){
Desktop.getDesktop().open(new File(fpath));
}
else{
MimeType mt = MimeTypesList.getMimeTypeForFile(fpath);
if (mt.getMimeTypeId().equals("__UNKNOWN")) {
mt = addResourceType(fpath);
if (mt == null)
return;
}
if (!checkApp(mt))
return;
}
// if file if projectFile, than copy the file and change url.
if (dlg.projectFileCB.isSelected()) {
fpath = copyFileToProjectDir(fpath);
CurrentProject.getResourcesList().addResource(fpath, false, true);
}
else
CurrentProject.getResourcesList().addResource(fpath);
resourcesTable.tableChanged();
}
catch (Exception ex){
ex.printStackTrace();
}
}
else {
if (!Util.checkBrowser())
return;
CurrentProject.getResourcesList().addResource(dlg.urlField.getText(), true, false);
resourcesTable.tableChanged();
}
}