当前位置: 首页>>代码示例>>Java>>正文


Java Loader.getMainFile方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:22,代码来源:ProjectActions.java

示例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;
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:24,代码来源:ProjectActions.java

示例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);
	}
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:21,代码来源:ProjectActions.java

示例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);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:9,代码来源:ProjectActions.java

示例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;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:12,代码来源:Projects.java

示例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);
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:9,代码来源:ProjectActions.java

示例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;
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:14,代码来源:Projects.java

示例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;
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:10,代码来源:Projects.java

示例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);
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:78,代码来源:ProjectActions.java

示例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);
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:51,代码来源:ProjectActions.java

示例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);
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:7,代码来源:ProjectActions.java


注:本文中的com.cburch.logisim.file.Loader.getMainFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。