本文整理汇总了Java中net.sf.memoranda.util.MimeTypesList类的典型用法代码示例。如果您正苦于以下问题:Java MimeTypesList类的具体用法?Java MimeTypesList怎么用?Java MimeTypesList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MimeTypesList类属于net.sf.memoranda.util包,在下文中一共展示了MimeTypesList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addResourceType
import net.sf.memoranda.util.MimeTypesList; //导入依赖的package包/类
MimeType addResourceType(String fpath) {
ResourceTypeDialog dlg = new ResourceTypeDialog(App.getFrame(), Local.getString("Resource type"));
Dimension dlgSize = new Dimension(420, 300);
dlg.setSize(dlgSize);
Dimension frmSize = App.getFrame().getSize();
Point loc = App.getFrame().getLocation();
dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.setVisible(true);
if (dlg.CANCELLED)
return null;
int ix = dlg.getTypesList().getSelectedIndex();
MimeType mt = (MimeType) MimeTypesList.getAllMimeTypes().toArray()[ix];
mt.addExtension(MimeTypesList.getExtension(fpath));
CurrentStorage.get().storeMimeTypesList();
return mt;
}
示例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: deleteB_actionPerformed
import net.sf.memoranda.util.MimeTypesList; //导入依赖的package包/类
void deleteB_actionPerformed(ActionEvent e) {
MimeType mt = (MimeType) typesList.getSelectedValue();
int n =
JOptionPane.showConfirmDialog(
App.getFrame(),
Local.getString("Delete resource type")
+ "\n'"
+ mt.getLabel()
+ "'\n"
+ Local.getString("Are you sure?"),
Local.getString("Delete resource type"),
JOptionPane.YES_NO_OPTION);
if (n != JOptionPane.YES_OPTION)
return;
MimeTypesList.removeMimeType(mt.getMimeTypeId());
CurrentStorage.get().storeMimeTypesList();
this.initTypesList();
}
示例4: addResourceType
import net.sf.memoranda.util.MimeTypesList; //导入依赖的package包/类
/**
* If the file type is indeterminable by the program, find the program
* and store the path to the Resources list.
* @param fpath
* @return
*/
MimeType addResourceType(String fpath) {
ResourceTypeDialog dlg = new ResourceTypeDialog(App.getFrame(), Local.getString("Resource type"));
Dimension dlgSize = new Dimension(420, 300);
dlg.setSize(dlgSize);
Dimension frmSize = App.getFrame().getSize();
Point loc = App.getFrame().getLocation();
dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.ext = MimeTypesList.getExtension(fpath);
dlg.setVisible(true);
if (dlg.CANCELLED)
return null;
int ix = dlg.getTypesList().getSelectedIndex();
MimeType mt = (MimeType) MimeTypesList.getAllMimeTypes().toArray()[ix];
mt.addExtension(MimeTypesList.getExtension(fpath));
CurrentStorage.get().storeMimeTypesList();
return mt;
}
示例5: deleteB_actionPerformed
import net.sf.memoranda.util.MimeTypesList; //导入依赖的package包/类
/**
* Delete a resource type and update the list.
* @param e
*/
void deleteB_actionPerformed(ActionEvent e) {
MimeType mt = (MimeType) typesList.getSelectedValue();
int n =
JOptionPane.showConfirmDialog(
App.getFrame(),
Local.getString("Delete resource type")
+ "\n'"
+ mt.getLabel()
+ "'\n"
+ Local.getString("Are you sure?"),
Local.getString("Delete resource type"),
JOptionPane.YES_NO_OPTION);
if (n != JOptionPane.YES_OPTION)
return;
MimeTypesList.removeMimeType(mt.getMimeTypeId());
CurrentStorage.get().storeMimeTypesList();
this.initTypesList();
}
示例6: addResourceType
import net.sf.memoranda.util.MimeTypesList; //导入依赖的package包/类
MimeType addResourceType(String fpath) {
ResourceTypeDialog dlg = new ResourceTypeDialog(App.getFrame(), Local.getString("Resource type"));
Dimension dlgSize = new Dimension(420, 300);
dlg.setSize(dlgSize);
Dimension frmSize = App.getFrame().getSize();
Point loc = App.getFrame().getLocation();
dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.ext = MimeTypesList.getExtension(fpath);
dlg.setVisible(true);
if (dlg.CANCELLED)
return null;
int ix = dlg.getTypesList().getSelectedIndex();
MimeType mt = (MimeType) MimeTypesList.getAllMimeTypes().toArray()[ix];
mt.addExtension(MimeTypesList.getExtension(fpath));
CurrentStorage.get().storeMimeTypesList();
return mt;
}
示例7: 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;
}
示例8: addResourceType
import net.sf.memoranda.util.MimeTypesList; //导入依赖的package包/类
MimeType addResourceType(String fpath) {
ResourceTypeDialog dlg = new ResourceTypeDialog(App.getFrame(), Local.getString("Resource type"));
Dimension dlgSize = new Dimension(420, 300);
dlg.setSize(dlgSize);
Dimension frmSize = App.getFrame().getSize();
Point loc = App.getFrame().getLocation();
dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.ext = MimeTypesList.getExtension(fpath);
dlg.setVisible(true);
if (dlg.CANCELLED)
return null;
int ix = dlg.getTypesList().getSelectedIndex();
MimeType mt = (MimeType) MimeTypesList.getAllMimeTypes().toArray()[ix];
mt.addExtension(MimeTypesList.getExtension(fpath));
CurrentStorage.get().storeMimeTypesList();
return mt;
}
示例9: 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).");
}
}
示例10: addResourceType
import net.sf.memoranda.util.MimeTypesList; //导入依赖的package包/类
MimeType addResourceType(String fpath) {
ResourceTypeDialog dlg = new ResourceTypeDialog(App.getFrame(), Local.getString("Resource type"));
Dimension dlgSize = new Dimension(420, 300);
dlg.setSize(dlgSize);
Dimension frmSize = App.getFrame().getSize();
Point loc = App.getFrame().getLocation();
dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.ext = MimeTypesList.getExtension(fpath);
dlg.setVisible(true);
if (dlg.CANCELLED) {
return null;
}
int ix = dlg.getTypesList().getSelectedIndex();
MimeType mt = (MimeType) MimeTypesList.getAllMimeTypes().toArray()[ix];
mt.addExtension(MimeTypesList.getExtension(fpath));
CurrentStorage.get().storeMimeTypesList();
return mt;
}
示例11: 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).");
}
}
示例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: initTypesList
import net.sf.memoranda.util.MimeTypesList; //导入依赖的package包/类
public void initTypesList() {
/*Vector v = new Vector();
icons = new Vector();
Vector t = MimeTypesList.getAllMimeTypes();
for (int i = 0; i < t.size(); i++) {
MimeType mt = (MimeType)t.get(i);
v.add(mt.getLabel());
icons.add(mt.getIcon());
}*/
typesList.setListData(MimeTypesList.getAllMimeTypes());
typesList.updateUI();
}
示例14: newTypeB_actionPerformed
import net.sf.memoranda.util.MimeTypesList; //导入依赖的package包/类
void newTypeB_actionPerformed(ActionEvent e) {
EditTypeDialog dlg = new EditTypeDialog(App.getFrame(), Local.getString("New resource type"));
Dimension dlgSize = new Dimension(420, 420);
dlg.setSize(dlgSize);
Dimension frmSize = App.getFrame().getSize();
Point loc = App.getFrame().getLocation();
dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.extField.setText(ext);
dlg.descField.setText(ext);
dlg.appPanel.argumentsField.setText("$1");
dlg.iconLabel.setIcon(
new ImageIcon(
net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/mimetypes/default.png")));
dlg.setVisible(true);
if (dlg.CANCELLED)
return;
String typeId = Util.generateId();
MimeType mt = MimeTypesList.addMimeType(typeId);
String[] exts = dlg.extField.getText().trim().split(" ");
for (int i = 0; i < exts.length; i++)
mt.addExtension(exts[i]);
mt.setLabel(dlg.descField.getText());
AppList appList = MimeTypesList.getAppList();
if (dlg.appPanel.applicationField.getText().length() > 0) {
File f = new File(dlg.appPanel.applicationField.getText());
String appId = Util.generateId();
appList.addApp(
appId,
f.getParent().replace('\\', '/'),
f.getName().replace('\\', '/'),
dlg.appPanel.argumentsField.getText());
mt.setApp(appId);
}
if (dlg.iconPath.length() > 0)
mt.setIconPath(dlg.iconPath);
CurrentStorage.get().storeMimeTypesList();
this.initTypesList();
typesList.setSelectedValue(mt, true);
}
示例15: 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;
}