本文整理汇总了Java中com.cburch.logisim.file.Loader.getMainFile方法的典型用法代码示例。如果您正苦于以下问题:Java Loader.getMainFile方法的具体用法?Java Loader.getMainFile怎么用?Java Loader.getMainFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.cburch.logisim.file.Loader
的用法示例。
在下文中一共展示了Loader.getMainFile方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doOpen
import com.cburch.logisim.file.Loader; //导入方法依赖的package包/类
public static void doOpen(Component parent, Project baseProject) {
JFileChooser chooser;
if (baseProject != null) {
Loader oldLoader = baseProject.getLogisimFile().getLoader();
chooser = oldLoader.createChooser();
if (oldLoader.getMainFile() != null) {
chooser.setSelectedFile(oldLoader.getMainFile());
}
} else {
chooser = JFileChoosers.create();
}
chooser.setFileFilter(Loader.LOGISIM_FILTER);
int returnVal = chooser.showOpenDialog(parent);
if (returnVal != JFileChooser.APPROVE_OPTION)
return;
File selected = chooser.getSelectedFile();
if (selected != null) {
doOpen(parent, baseProject, selected);
}
}
示例2: doOpen
import com.cburch.logisim.file.Loader; //导入方法依赖的package包/类
public static boolean doOpen(Component parent, Project baseProject) {
JFileChooser chooser;
if (baseProject != null) {
Loader oldLoader = baseProject.getLogisimFile().getLoader();
chooser = oldLoader.createChooser();
if (oldLoader.getMainFile() != null) {
chooser.setSelectedFile(oldLoader.getMainFile());
}
} else {
chooser = JFileChoosers.create();
}
chooser.setFileFilter(Loader.LOGISIM_FILTER);
chooser.setDialogTitle(Strings.get("FileOpenItem"));
int returnVal = chooser.showOpenDialog(parent);
if (returnVal != JFileChooser.APPROVE_OPTION)
return false;
File selected = chooser.getSelectedFile();
if (selected != null) {
doOpen(parent, baseProject, selected);
}
return true;
}
示例3: doOpen
import com.cburch.logisim.file.Loader; //导入方法依赖的package包/类
public static void doOpen(Component parent, Project baseProject) {
JFileChooser chooser;
if (baseProject != null) {
Loader oldLoader = baseProject.getLogisimFile().getLoader();
chooser = oldLoader.createChooser();
if (oldLoader.getMainFile() != null) {
chooser.setSelectedFile(oldLoader.getMainFile());
}
} else {
chooser = JFileChoosers.create();
}
chooser.setFileFilter(Loader.LOGISIM_FILTER);
int returnVal = chooser.showOpenDialog(parent);
if (returnVal != JFileChooser.APPROVE_OPTION) return;
File selected = chooser.getSelectedFile();
if (selected != null) {
doOpen(parent, baseProject, selected);
}
}
示例4: doSave
import com.cburch.logisim.file.Loader; //导入方法依赖的package包/类
public static boolean doSave(Project proj) {
Loader loader = proj.getLogisimFile().getLoader();
File f = loader.getMainFile();
if (f == null)
return doSaveAs(proj, true);
else
return doSave(proj, f);
}
示例5: findProjectFor
import com.cburch.logisim.file.Loader; //导入方法依赖的package包/类
public static Project findProjectFor(File query) {
for (Project proj : openProjects) {
Loader loader = proj.getLogisimFile().getLoader();
if (loader == null)
continue;
File f = loader.getMainFile();
if (query.equals(f))
return proj;
}
return null;
}
示例6: doSave
import com.cburch.logisim.file.Loader; //导入方法依赖的package包/类
public static boolean doSave(Project proj) {
Loader loader = proj.getLogisimFile().getLoader();
File f = loader.getMainFile();
if (f == null)
return doSaveAs(proj);
else
return doSave(proj, f);
}
示例7: findProjectFor
import com.cburch.logisim.file.Loader; //导入方法依赖的package包/类
public static Project findProjectFor(File query) {
for (Project proj : openProjects) {
Loader loader = proj.getLogisimFile().getLoader();
if (loader == null) {
continue;
}
File f = loader.getMainFile();
if (query.equals(f)) {
return proj;
}
}
return null;
}
示例8: findProjectFor
import com.cburch.logisim.file.Loader; //导入方法依赖的package包/类
public static Project findProjectFor(File query) {
for (Project proj : openProjects) {
Loader loader = proj.getLogisimFile().getLoader();
if (loader == null) continue;
File f = loader.getMainFile();
if (query.equals(f)) return proj;
}
return null;
}
示例9: doSaveAs
import com.cburch.logisim.file.Loader; //导入方法依赖的package包/类
/**
* Saves a Logisim project in a .circ file.
*
* It is the action listener for the File->Save as... menu option.
*
* @param proj
* project to be saved
* @return true if success, false otherwise
*/
public static boolean doSaveAs(Project proj) {
Loader loader = proj.getLogisimFile().getLoader();
JFileChooser chooser = loader.createChooser();
chooser.setFileFilter(Loader.LOGISIM_FILTER);
if (loader.getMainFile() != null) {
chooser.setSelectedFile(loader.getMainFile());
}
int returnVal;
boolean validFilename = false;
HashMap<String,String> Error = new HashMap<String,String> ();
do {
Error.clear();
returnVal = chooser.showSaveDialog(proj.getFrame());
if (returnVal != JFileChooser.APPROVE_OPTION) {
return false;
}
validFilename = checkValidFilename(chooser.getSelectedFile() .getName(),proj,Error);
if (!validFilename) {
String Message = "\""+chooser.getSelectedFile()+"\":\n";
for (String key : Error.keySet())
Message = Message.concat("=> "+Strings.get(Error.get(key))+"\n");
JOptionPane.showMessageDialog(chooser,Message,Strings.get("FileSaveAsItem"),JOptionPane.ERROR_MESSAGE);
}
} while (!validFilename);
File f = chooser.getSelectedFile();
String circExt = Loader.LOGISIM_EXTENSION;
if (!f.getName().endsWith(circExt)) {
String old = f.getName();
int ext0 = old.lastIndexOf('.');
if (ext0 < 0
|| !Pattern.matches("\\.\\p{L}{2,}[0-9]?",
old.substring(ext0))) {
f = new File(f.getParentFile(), old + circExt);
} else {
String ext = old.substring(ext0);
String ttl = Strings.get("replaceExtensionTitle");
String msg = Strings.get("replaceExtensionMessage", ext);
Object[] options = {
Strings.get("replaceExtensionReplaceOpt", ext),
Strings.get("replaceExtensionAddOpt", circExt),
Strings.get("replaceExtensionKeepOpt") };
JOptionPane dlog = new JOptionPane(msg);
dlog.setMessageType(JOptionPane.QUESTION_MESSAGE);
dlog.setOptions(options);
dlog.createDialog(proj.getFrame(), ttl).setVisible(true);
Object result = dlog.getValue();
if (result == options[0]) {
String name = old.substring(0, ext0) + circExt;
f = new File(f.getParentFile(), name);
} else if (result == options[1]) {
f = new File(f.getParentFile(), old + circExt);
}
}
}
if (f.exists()) {
int confirm = JOptionPane.showConfirmDialog(proj.getFrame(),
Strings.get("confirmOverwriteMessage"),
Strings.get("confirmOverwriteTitle"),
JOptionPane.YES_NO_OPTION);
if (confirm != JOptionPane.YES_OPTION)
return false;
}
return doSave(proj, f);
}
示例10: doSaveAs
import com.cburch.logisim.file.Loader; //导入方法依赖的package包/类
public static boolean doSaveAs(Project proj) {
Loader loader = proj.getLogisimFile().getLoader();
JFileChooser chooser = loader.createChooser();
chooser.setFileFilter(Loader.LOGISIM_FILTER);
if (loader.getMainFile() != null) {
chooser.setSelectedFile(loader.getMainFile());
}
int returnVal = chooser.showSaveDialog(proj.getFrame());
if (returnVal != JFileChooser.APPROVE_OPTION) return false;
File f = chooser.getSelectedFile();
String circExt = Loader.LOGISIM_EXTENSION;
if (!f.getName().endsWith(circExt)) {
String old = f.getName();
int ext0 = old.lastIndexOf('.');
if (ext0 < 0 || !Pattern.matches("\\.\\p{L}{2,}[0-9]?", old.substring(ext0))) {
f = new File(f.getParentFile(), old + circExt);
} else {
String ext = old.substring(ext0);
String ttl = Strings.get("replaceExtensionTitle");
String msg = Strings.get("replaceExtensionMessage", ext);
Object[] options = {
Strings.get("replaceExtensionReplaceOpt", ext),
Strings.get("replaceExtensionAddOpt", circExt),
Strings.get("replaceExtensionKeepOpt")
};
JOptionPane dlog = new JOptionPane(msg);
dlog.setMessageType(JOptionPane.QUESTION_MESSAGE);
dlog.setOptions(options);
dlog.createDialog(proj.getFrame(), ttl).setVisible(true);
Object result = dlog.getValue();
if (result == options[0]) {
String name = old.substring(0, ext0) + circExt;
f = new File(f.getParentFile(), name);
} else if (result == options[1]) {
f = new File(f.getParentFile(), old + circExt);
}
}
}
if (f.exists()) {
int confirm = JOptionPane.showConfirmDialog(proj.getFrame(),
Strings.get("confirmOverwriteMessage"),
Strings.get("confirmOverwriteTitle"),
JOptionPane.YES_NO_OPTION);
if (confirm != JOptionPane.YES_OPTION) return false;
}
return doSave(proj, f);
}
示例11: doSave
import com.cburch.logisim.file.Loader; //导入方法依赖的package包/类
public static boolean doSave(Project proj) {
Loader loader = proj.getLogisimFile().getLoader();
File f = loader.getMainFile();
if (f == null) return doSaveAs(proj);
else return doSave(proj, f);
}