本文整理匯總了Java中org.eclipse.core.resources.IFile.exists方法的典型用法代碼示例。如果您正苦於以下問題:Java IFile.exists方法的具體用法?Java IFile.exists怎麽用?Java IFile.exists使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IFile的用法示例。
在下文中一共展示了IFile.exists方法的20個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: generateTestImplementation
點讚 3
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Generate a test implementation if it does not exist
*
* @param implementationFolder
* @param implementationFragmentRoot
* @param targetPkg
* @param interfaceCompUnit
* @param monitor
* @throws CoreException
*/
public static IFile generateTestImplementation(TestResourceGeneration provider, IProgressMonitor monitor)
throws Exception {
IFile ifile = provider.toIFile();
if (ifile.exists()) {
JDTManager.rename(ifile, monitor);
ifile.delete(true, monitor);
}
if (ifile.exists())
return null;
NewExecutionContextClassWizardPageRunner execRunner = new NewExecutionContextClassWizardPageRunner(provider,
monitor);
Display.getDefault().syncExec(execRunner);
IPath path = execRunner.getType().getPath();
IFile createdFile = (IFile) ResourceManager.getResource(path.toString());
return createdFile;
}
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:30,
示例2: tryLocateGeneratedFile
點讚 3
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
private IFile tryLocateGeneratedFile(final IFile file, final String genID) {
final URI fileUri = createPlatformResourceURI(file.getFullPath().toOSString(), true);
if (fileUri.isPlatform()) {
final Optional extends IN4JSProject> project = core.findProject(fileUri);
if (project.isPresent()) {
try {
final String targetFileName = compilerHelper.getTargetFileName(fileUri, JS_FILE_EXTENSION);
final String targetFileRelativeLocation = project.get().getOutputPath() + "/"
// TODO replace hard coded ES5 sub-generator ID once it is clear how to use various
// sub-generators for runners (IDE-1487)
+ genID + "/" + targetFileName;
final IFile targetFile = file.getProject().getFile(targetFileRelativeLocation);
if (targetFile.exists()) {
return targetFile;
}
} catch (final GeneratorException e) {
// file is not contained in a source container.
return null;
}
}
}
return null;
}
開發者ID:eclipse,項目名稱:n4js,代碼行數:24,
示例3: validatePage
點讚 3
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
protected boolean validatePage() {
boolean returnCode= super.validatePage() && validateFilename();
if(returnCode){
IPath iPath=new Path(getContainerFullPath()+JOBS_FOLDER_NAME);
IFolder folder=ResourcesPlugin.getWorkspace().getRoot().getFolder(iPath);
if(!StringUtils.endsWithIgnoreCase(getFileName(), Constants.JOB_EXTENSION)){
IFile newFile= folder.getFile(getFileName()+Constants.JOB_EXTENSION);
if(newFile.exists()){
setErrorMessage("'"+newFile.getName()+"'"+Constants.ALREADY_EXISTS);
return false;
}
}
}
return returnCode;
}
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:17,
示例4: removeTempSubJobTrackFiles
點讚 3
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Remove temp tracking subjob file after tool close, rerun and modification.
*/
public void removeTempSubJobTrackFiles() {
if(deleteOnDispose){
try {
IFile file=((IFileEditorInput)getEditorInput()).getFile();
if(file.exists()){
ResourcesPlugin.getWorkspace().getRoot().getFile(file.getFullPath()).delete(true, null);
ResourcesPlugin.getWorkspace().getRoot().getFile(file.getFullPath().removeFileExtension().addFileExtension(Constants.XML_EXTENSION_FOR_IPATH)).delete(true, null);
}
} catch (Exception e) {
logger.error("Failed to remove temp subjob tracking files: "+e);
}
}
}
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:19,
示例5: getIFile
點讚 3
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
static public IFile getIFile(String filePath, boolean checkExistency) {
String cleanPath = cleanIfNecessaryPath(filePath);
Path path = new Path(cleanPath);
try {
IFile file = root.getFile(path);
if ( ! checkExistency )
return file;
else {
if ( file.exists() )
return file;
else
return null;
}
} catch (java.lang.IllegalArgumentException exception) {
return null;
}
}
開發者ID:eclipse,項目名稱:gemoc-studio,代碼行數:18,
示例6: getModelOutputFile
點讚 3
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public File getModelOutputFile (String outputName) throws CoreException, InterruptedException, FileNotFoundException {
IFile file = ResourceManager.toIFile(sourceFileModel);
IFolder folder = ResourceManager.ensureFolder(file.getProject(), ".gw4eoutput", new NullProgressMonitor());
IFile outfile = folder.getFile(new Path(outputName));
InputStream source = new ByteArrayInputStream("".getBytes());
if (outfile.exists()) {
outfile.setContents(source, IResource.FORCE, new NullProgressMonitor());
} else {
outfile.create(source, IResource.FORCE, new NullProgressMonitor());
}
outfile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
long max = System.currentTimeMillis() + 15 * 1000;
while (true) {
IFile out = folder.getFile(new Path(outputName));
if (out.exists()) break;
if (System.currentTimeMillis() > max) {
throw new InterruptedException (out.getFullPath() + " does not exist.");
}
Thread.sleep(500);
}
return ResourceManager.toFile(outfile.getFullPath());
}
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:25,
示例7: createClasspathEntries
點讚 3
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
@Override
public List createClasspathEntries()
{
IPath srcJar = null;
if( underlyingResource.getFileExtension().equals("jar") )
{
String name = underlyingResource.getName();
IFile srcJarFile = underlyingResource.getProject().getFile(
"lib-src/" + name.substring(0, name.length() - 4) + "-sources.jar");
if( srcJarFile.exists() )
{
srcJar = srcJarFile.getFullPath();
}
}
return Arrays.asList(JavaCore.newLibraryEntry(underlyingResource.getFullPath(), srcJar, null));
}
開發者ID:equella,項目名稱:Equella,代碼行數:17,
示例8: addJvmOptions
點讚 3
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
private void addJvmOptions ( final ILaunchConfigurationWorkingCopy cfg, final Profile profile, final IContainer container ) throws CoreException
{
final List args = new LinkedList<> ();
args.addAll ( profile.getJvmArguments () );
for ( final SystemProperty p : profile.getProperty () )
{
addSystemProperty ( profile, args, p.getKey (), p.getValue (), p.isEval () );
}
for ( final Map.Entry entry : getInitialProperties ().entrySet () )
{
addSystemProperty ( profile, args, entry.getKey (), entry.getValue (), false );
}
final IFile dataJson = container.getFile ( new Path ( "data.json" ) ); //$NON-NLS-1$
if ( dataJson.exists () )
{
addJvmArg ( args, "org.eclipse.scada.ca.file.provisionJsonUrl", escapeArgValue ( dataJson.getLocation ().toFile ().toURI ().toString () ) ); //$NON-NLS-1$
}
cfg.setAttribute ( IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, StringHelper.join ( args, "\n" ) );
cfg.setAttribute ( IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, StringHelper.join ( profile.getArguments (), "\n" ) );
}
開發者ID:eclipse,項目名稱:neoscada,代碼行數:26,
示例9: updateFileExtension
點讚 2
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Updates the file extension according to the current selection. (tree + element name input)
*/
private void updateFileExtension() {
Object selection = treeViewer.getStructuredSelection().getFirstElement();
String elementFileName = elementNameInput.getText();
if (null == selection) {
setFileExtension(defaultFileExtension);
}
// If an existing file is selected and element name input equals its name
if (selection instanceof IFile && elementFileName.equals(((IFile) selection).getName())) {
// Use the file's extension
setFileExtension(((IFile) selection).getFileExtension());
} else if (selection instanceof IResource) {
// Otherwise compute the path of the selected element
IPath basepath;
if (selection instanceof IFile) {
basepath = ((IFile) selection).getParent().getFullPath();
} else {
basepath = ((IResource) selection).getFullPath();
}
IPath pathOfSelection = basepath.append(elementFileName);
IFile n4jsFile = workspaceRoot.getFile(pathOfSelection.addFileExtension(N4JSGlobals.N4JS_FILE_EXTENSION));
IFile n4jsdFile = workspaceRoot.getFile(pathOfSelection.addFileExtension(N4JSGlobals.N4JSD_FILE_EXTENSION));
// If a n4js or n4jsd file with the specified location exists, use the proper file extension. Otherwise use
// the default file extension.
if (n4jsdFile.exists()) {
setFileExtension(N4JSGlobals.N4JSD_FILE_EXTENSION);
} else if (n4jsFile.exists()) {
setFileExtension(N4JSGlobals.N4JS_FILE_EXTENSION);
} else {
setFileExtension(defaultFileExtension);
}
}
}
開發者ID:eclipse,項目名稱:n4js,代碼行數:40,
示例10: run
點讚 2
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
//System.out.println("OcciRegistry" + OcciRegistry.getInstance().getRegisteredExtensions()) ;
//System.out.println(" selection "+selection);
Iterator> it = ((IStructuredSelection) selection).iterator();
int i= 0;
String message="\n";
while (it.hasNext()) {
IProject selectedProject = (IProject)it.next();
if(selectedProject instanceof IProject) {
// Generate plugin.xml
IFile pluginXML = PDEProject.getPluginXml(selectedProject);
if(pluginXML.exists()) {
if (!(getExtensionScheme(pluginXML).equals("") || getExtensionURI(pluginXML).equals(""))) {
//System.out.println(" selectedElement "+selectedProject +" "+selectedProject.getClass());
//System.out.println(" selectedElement "+getExtensionScheme(pluginXML));
//System.out.println(" selectedElement "+getExtensionURI(pluginXML));
OcciRegistry.getInstance().registerExtension(getExtensionScheme(pluginXML), getExtensionURI(pluginXML));
closeOtherSessions(selectedProject);
i++;
message = message.concat(getExtensionScheme(pluginXML)).concat("\n");
}
}
}
}
if(i>0)
MessageDialog.openInformation(shell,
Messages.RegisterExtensionAction_ExtRegistration,
Messages.RegisterExtensionAction_RegisteredExtension
+message);
}
開發者ID:occiware,項目名稱:OCCI-Studio,代碼行數:35,
示例11: write
點讚 2
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* @param factory
* @param file
* @throws IOException
*/
private static List write(ContextFactory factory, SourceFile file, boolean erase, IProgressMonitor monitor)
throws IOException {
List ret = new ArrayList();
List contexts = factory.create(file.getInputPath());
for (Context context : contexts) {
try {
RuntimeModel model = context.getModel();
File outfile = file.getOutputPath().toFile();
if (erase) {
IFile ifileTodelete = ResourceManager.toIFile(outfile);
if (ifileTodelete.exists()) {
ifileTodelete.delete(true, monitor);
}
}
String source = new CodeGenerator().generate(file, model);
File f = file.getOutputPath().getParent().toFile();
IFolder ifolder = ResourceManager.toIFolder(f);
ResourceManager.ensureFolder((IFolder) ifolder);
IFile ifile = ResourceManager.createFileDeleteIfExists(file.getOutputPath().toFile(), source, monitor);
ret.add(ifile.getFullPath());
} catch (Throwable t) {
ResourceManager.logException(t);
}
}
return ret;
}
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:36,
示例12: getBuildPoliciesForGraph
點讚 2
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* @param file
* @return The build policies file located in the same folder as the graph
* file
* @throws FileNotFoundException
*/
public static IFile getBuildPoliciesForGraph(IFile file) throws FileNotFoundException {
String name = PreferenceManager.getBuildPoliciesFileName(file.getProject().getName());
IFolder folder = (IFolder) file.getParent();
IFile policiesFile = folder.getFile(name);
if (policiesFile == null || !policiesFile.exists())
throw new FileNotFoundException(folder.getFullPath().append(name).toString());
return policiesFile;
}
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:15,
示例13: getErrorMessageIfUserDeletePropertyRelatedFiles
點讚 2
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
private String getErrorMessageIfUserDeletePropertyRelatedFiles(IFile jobFileName, IFile xmlFileName) {
String message = "";
if (jobFileName != null && xmlFileName != null) {
if ((jobFileName.exists()) && (!xmlFileName.exists())) {
message = Messages.SHOW_ERROR_MESSAGE_ON_DELETING_PROPERTY_RELATED_JOB_RESOURCE;
} else if (!jobFileName.exists() && xmlFileName.exists()) {
message = Messages.SHOW_ERROR_MESSAGE_ON_DELETING_PROPERTY_RELATED_XML_RESOURCE;
} else if (jobFileName.exists() && xmlFileName.exists()) {
message = Messages.SHOW_ERROR_MESSAGE_ON_DELETING_PROPERTY_RELATED_RESOURCE;
}
}
return message;
}
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:14,
示例14: createFile
點讚 2
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* @param file
* @throws CoreException
* @throws FileNotFoundException
* @throws InterruptedException
*/
public static File createFile(IFile file, IProgressMonitor monitor) throws CoreException, FileNotFoundException {
if (file.exists()) {
return ResourceManager.toFile(file.getFullPath());
}
byte[] content = "".getBytes(Charset.forName("UTF-8"));
file.create(new ByteArrayInputStream(content), IResource.KEEP_HISTORY, monitor);
IResource resource = getWorkspaceRoot().findMember(file.getFullPath());
IPath path = resource.getRawLocation();
return new File(path.makeAbsolute().toString());
}
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:18,
示例15: createFileDeleteIfExists
點讚 2
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Create a file in a folder with the specified name and content
*
* @param fullpath
* @param filename
* @param content
* @throws CoreException
* @throws InterruptedException
*/
public static IFile createFileDeleteIfExists(File file, String content, IProgressMonitor monitor)
throws CoreException, InterruptedException {
IFile newFile = ResourceManager.toIFile(file);
if (newFile.exists()) {
JDTManager.rename(newFile, monitor);
newFile.delete(true, monitor);
}
byte[] source = content.getBytes(Charset.forName("UTF-8"));
newFile.create(new ByteArrayInputStream(source), true, monitor);
return newFile;
}
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:23,
示例16: updateProjectPluginConfiguration
點讚 2
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Update plugin.xml according to the model
*
* @param resource
*/
private void updateProjectPluginConfiguration(IResource resource) {
if (resource instanceof IFile
&& resource.getFileExtension().equals("melange")) {
IFile file = (IFile) resource;
IProject project = file.getProject();
// try {
if (file.exists()) {
//Load .melange file
URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
ResourceSet rs = new ResourceSetImpl();
Resource res = rs.getResource(uri, true);
ModelTypingSpace root = (ModelTypingSpace)res.getContents().get(0);
String packageName = root.getName();
//Browse declared Languages
for (fr.inria.diverse.melange.metamodel.melange.Element element : root.getElements()) {
if(element instanceof Language){
Language language = (Language) element;
// update entry in plugin.xml
setPluginLanguageNameAndFilePath(project, file, packageName+"."+language.getName());
}
}
//Use default model loader
updateModelLoaderClass(project, null);
ManifestChanger manifestChanger = new ManifestChanger(project);
try {
manifestChanger.addPluginDependency(org.eclipse.gemoc.executionframework.extensions.sirius.Activator.PLUGIN_ID);
manifestChanger.commit();
} catch (BundleException | IOException | CoreException e) {
e.printStackTrace();
}
}
}
}
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:42,
示例17: addResource
點讚 2
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
private void addResource ( final IProject project, final String name, final InputStream stream, final IProgressMonitor monitor ) throws CoreException
{
try
{
final String[] toks = name.split ( "\\/" ); //$NON-NLS-1$
IContainer container = project;
for ( int i = 0; i < toks.length - 1; i++ )
{
final IFolder folder = container.getFolder ( new Path ( toks[i] ) );
if ( !folder.exists () )
{
folder.create ( true, true, null );
}
container = folder;
}
final IFile file = project.getFile ( name );
if ( file.exists () )
{
file.setContents ( stream, IResource.FORCE, monitor );
}
else
{
file.create ( stream, true, monitor );
}
}
finally
{
try
{
stream.close ();
}
catch ( final IOException e )
{
}
}
monitor.done ();
}
開發者ID:eclipse,項目名稱:neoscada,代碼行數:38,
示例18: marshall
點讚 2
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public void marshall(Debug debug,IFile outPutFile) throws JAXBException, IOException, CoreException{
JAXBContext jaxbContext = JAXBContext.newInstance(Debug.class);
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
ByteArrayOutputStream out = new ByteArrayOutputStream();
marshaller.marshal(debug, out);
if (outPutFile.exists())
outPutFile.setContents(new ByteArrayInputStream(out.toByteArray()), true,false, null);
else
outPutFile.create(new ByteArrayInputStream(out.toByteArray()),true, null);
out.close();
}
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:15,
示例19: getUserFunctionsPropertertyFile
點讚 2
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Gets the user functions properterty file.
*
* @return the user functions properterty file
*/
protected String getUserFunctionsPropertertyFile() {
String userFunctionsPropertyFileRelativePath="";
IProject project=getCurrentProjectFromActiveGraph();
if(project!=null){
IFolder folder=project.getFolder("resources");
if(folder.exists()){
IFile file=folder.getFile("UserFunctions.properties");
if(file.exists()){
userFunctionsPropertyFileRelativePath=file.getProjectRelativePath().toString();
}
}
}
return userFunctionsPropertyFileRelativePath;
}
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:20,
示例20: run
點讚 2
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
try {
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
Transaction transaction = null;
Connector connector = null;
TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
if (treeObject instanceof TransactionTreeObject) {
transaction = (Transaction)treeObject.getObject();
connector = (Connector) transaction.getParent();
if (transaction instanceof TransactionWithVariables) {
TransactionWithVariables tr = (TransactionWithVariables)transaction;
//if (tr.getVariablesDefinitionSize() == 0) {
if (tr.numberOfVariables() == 0) {
MessageBox messageBox = new MessageBox(shell, SWT.YES | SWT.APPLICATION_MODAL);
messageBox.setMessage("No variables are defined for transaction " + tr.getName());
messageBox.open();
} else {
String xslContent = generateXSLForm(connector, tr);
// Refresh project resource
IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(tr.getProject().getName());
// Compute the targetXSL file name
String xslForm = tr.getName()+"Request.xsl";
IFile file = project.getFile(xslForm);
ByteArrayInputStream bais = new ByteArrayInputStream(xslContent.getBytes());
if (file.exists()) {
file.setContents((InputStream)bais, IFile.FORCE | IFile.KEEP_HISTORY, null);
} else {
file.create((InputStream)bais, true, null);
}
TransactionWithVariables newTrans = (TransactionWithVariables)tr.clone();
newTrans.hasChanged = true;
newTrans.bNew = true;
XMLVector> orderedVariables = new XMLVector>();
orderedVariables.add(new XMLVector());
newTrans.setOrderedVariables(orderedVariables);
newTrans.setSheetLocation(Transaction.SHEET_LOCATION_FROM_REQUESTABLE);
HandlerStatement handler = new HandlerStatement(HandlerStatement.EVENT_TRANSACTION_STARTED, HandlerStatement.RETURN_CANCEL);
newTrans.add(handler);
newTrans.setName(tr.getName()+"Request");
Sheet sheet = new Sheet();
sheet.setBrowser("*");
sheet.setUrl(xslForm);
newTrans.addSheet(sheet);
connector.add(newTrans);
postCreate(treeObject.getConnectorTreeObject(), newTrans);
}
}
}
}
}
catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to generate a requestForm widget");
}
finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:75,
注:本文中的org.eclipse.core.resources.IFile.exists方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。