📄 myeclipseswisstools.java
字号:
package com.thalesgroup.cheddar.MARTE2cheddar.tools;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
/**
* Some useful commonly used functions
* <copyright>
* Thales MARTE to Cheddar (Copyright (c) THALES 2007 All rights reserved) is free software; you can redistribute itand/or modify
* it under the terms of the Eclipse Public License as published in http://www.eclipse.org/legal/epl-v10.html
*
* Thales MARTE to Cheddar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Eclipse Public License for more details.
* </copyright>
* @author Nicolas
*
*/
public class MyEclipseSwissTools {
/**
* Return an IFile by changing the extension on the input IFile
* @param file
* @param extension
* @return
*/
public static IFile ChangeFileExtension(IFile file, String extension) {
IProject p = file.getProject();
IPath outpath = file.getProjectRelativePath().removeFileExtension().addFileExtension(extension);
return p.getFile(outpath);
}
/**
* Return the IFile corresponding to the resource
* @param resource
* @return
*/
public static IFile getIFile(Resource resource) {
URI uri = resource.getURI();
IPath path = new Path(uri.path()).removeFirstSegments(1);
IWorkspaceRoot wr = ResourcesPlugin.getWorkspace().getRoot();
return wr.getFile(path);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -