本文整理匯總了Java中org.eclipse.core.resources.IFile.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java IFile.getName方法的具體用法?Java IFile.getName怎麽用?Java IFile.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IFile
的用法示例。
在下文中一共展示了IFile.getName方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateBuildPolicyFileFor
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* @param file
*/
public static void updateBuildPolicyFileFor(IFile file) {
Job job = new WorkspaceJob("Updating Build Policies from " + file.getName()) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
ICompilationUnit compilationUnit = JavaCore.createCompilationUnitFrom(file);
if (compilationUnit != null) {
if (JDTManager.isGraphWalkerExecutionContextClass(compilationUnit)) {
updateBuildPolicyFileForCompilatioUnit(compilationUnit);
}
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.setRule(file.getProject());
job.schedule();
}
示例2: execute
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IFile file = getSelectedFile();
if (file==null){
return null;
}
IWorkbenchPage page = EclipseUtil.getActivePage();
if (page==null){
return null;
}
try {
page.openEditor(new FileEditorInput(file), BashEditor.EDITOR_ID);
} catch (PartInitException e) {
throw new ExecutionException("Was not able to open bash editor for file:"+file.getName(),e);
}
return null;
}
示例3: testUpdatePathGeneratorInSourceFile
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
@Test
public void testUpdatePathGeneratorInSourceFile () throws CoreException, FileNotFoundException {
System.out.println("XXXXXXXXXXXXXXXXXXXX testUpdatePathGeneratorInSourceFile");
String expectedNewGenerator = "random(vertex_coverage(50))";
PetClinicProject.create (bot,gwproject); // At this step the generator is "random(edge_coverage(100))"
IFile veterinarien = PetClinicProject.getVeterinariensSharedStateImplFile(gwproject);
ICompilationUnit cu = JavaCore.createCompilationUnitFrom(veterinarien);
String oldGenerator = JDTManager.findPathGeneratorInGraphWalkerAnnotation(cu);
SourceHelper.updatePathGenerator(veterinarien, oldGenerator, expectedNewGenerator);
cu = JavaCore.createCompilationUnitFrom(veterinarien);
String newGenerator = JDTManager.findPathGeneratorInGraphWalkerAnnotation(cu);
assertEquals(newGenerator,expectedNewGenerator);
String location = JDTManager.getGW4EGeneratedAnnotationValue(cu,"value");
IPath path = new Path (gwproject).append(location);
IFile graphModel = (IFile)ResourceManager.getResource(path.toString());
IPath buildPolicyPath = ResourceManager.getBuildPoliciesPathForGraphModel(graphModel);
IFile buildPolicyFile = (IFile)ResourceManager.getResource(buildPolicyPath.toString());
PropertyValueCondition condition = new PropertyValueCondition(buildPolicyFile,graphModel.getName(),"random(edge_coverage(100));I;random(vertex_coverage(50));I;");
bot.waitUntil(condition);
}
示例4: generateBug
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Launch an file, using the file information, which means using default launch configurations.
*/
protected void generateBug(IFile fileSelectedToRun) {
String content = "";
try {
content = new String(Files.readAllBytes(Paths.get(fileSelectedToRun.getRawLocationURI())));
} catch (IOException e) {
throw new RuntimeException("Cannot read provided file " + fileSelectedToRun.getName(), e);
}
System.out.println(content);
generateAndDisplayReport(fileSelectedToRun.getName(), content);
}
示例5: rename
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* @param ifile
* @param monitor
* @throws JavaModelException
*/
public static void rename(IFile ifile, IProgressMonitor monitor) throws JavaModelException {
if (!ifile.getName().endsWith(".java"))
return;
ICompilationUnit unit = JavaCore.createCompilationUnitFrom(ifile);
String name = ifile.getName();
String[] segments = name.split("\\.");
name = segments[0] + System.currentTimeMillis() + "." + segments[1];
unit.rename(name, false, monitor);
unit.close();
}
示例6: isJUnitResultFile
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public static boolean isJUnitResultFile(IFile file) throws CoreException {
String filename = file.getName();
String extension = file.getFileExtension();
if (filename.startsWith("TEST-GraphWalker-") && "xml".equalsIgnoreCase(extension)) {
return true;
}
return false;
}
示例7: stripFileExtension
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Return the file name of the passed selection without its extension file,
* if it is a file ...
*
* @param selection
* @return
*/
public static String stripFileExtension(IStructuredSelection selection) {
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (!(obj instanceof IFile))
return "";
IFile file = ((IFile) obj);
String extension = file.getFileExtension();
String name = file.getName();
int pos = name.indexOf("." + extension);
return name.substring(0, pos);
}
示例8: testInvalidGeneratorInSourceFile
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
@Test
public void testInvalidGeneratorInSourceFile () throws CoreException, FileNotFoundException {
System.out.println("XXXXXXXXXXXXXXXXXXXX testInvalidGeneratorInSourceFile");
String expectedNewGenerator = "xxx";
PetClinicProject.create (bot,gwproject); // At this step the generator is "random(edge_coverage(100))"
IFile veterinarien = PetClinicProject.getVeterinariensSharedStateImplFile(gwproject);
ICompilationUnit cu = JavaCore.createCompilationUnitFrom(veterinarien);
String oldGenerator = JDTManager.findPathGeneratorInGraphWalkerAnnotation(cu);
SourceHelper.updatePathGenerator(veterinarien, oldGenerator, expectedNewGenerator);
cu = JavaCore.createCompilationUnitFrom(veterinarien);
String newGenerator = JDTManager.findPathGeneratorInGraphWalkerAnnotation(cu);
assertEquals(newGenerator,expectedNewGenerator);
GW4EProject project = new GW4EProject(bot, gwproject);
project.cleanBuild();
String expectedErrorMessageInProblemView = "Invalid path generator : '"+ expectedNewGenerator + "'";
ProblemView pv = ProblemView.open(bot);
List<ResolutionMarkerDescription> markers = PathGeneratorDescription.getDescriptions();
pv.executeQuickFixForErrorMessage(
expectedErrorMessageInProblemView,
markers.get(0).toString(),
new ICondition [] {new NoErrorInProblemView(pv)}
);
pv.close();//Mandatory
String graphmlSourcePath = JDTManager.getGW4EGeneratedAnnotationValue(cu,"value");
IPath path = new Path (gwproject).append(graphmlSourcePath);
IFile graphModel = (IFile)ResourceManager.getResource(path.toString());
IPath buildPolicyPath = ResourceManager.getBuildPoliciesPathForGraphModel(graphModel);
IFile buildPolicyFile = (IFile)ResourceManager.getResource(buildPolicyPath.toString());
PropertyValueCondition condition = new PropertyValueCondition(buildPolicyFile,graphModel.getName(),"random(vertex_coverage(100));I;random(edge_coverage(100));I;");
bot.waitUntil(condition);
}
示例9: getGraphName
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Gets the graph name.
*
* @param outPutFile the out put file
* @param externalOutputFile the external output file
* @return the graph name
*/
private String getGraphName(IFile outPutFile, IFileStore externalOutputFile) {
if (outPutFile != null && StringUtils.isNotBlank(outPutFile.getName()))
return outPutFile.getName();
else if (externalOutputFile != null && StringUtils.isNotBlank(externalOutputFile.getName()))
return externalOutputFile.getName();
else
return "Temp.xml";
}
示例10: makeResourceItem
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
private static ResourceItem makeResourceItem(IFile file) {
return new ResourceItem(file.getName(), makePathOnly(file.getProjectRelativePath()), file.getProject().getName());
}
示例11: createSimpleGraph
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public static GWGraph createSimpleGraph(IFile file) {
GWGraph gWGraph = new GWGraph(UUID.randomUUID(),file.getName(),UUID.randomUUID().toString());
gWGraph.setFile(file);
Vertex v1 = new StartVertex(gWGraph,UUID.randomUUID(),"v1",UUID.randomUUID().toString()) ;
Vertex v2 = new Vertex(gWGraph,UUID.randomUUID(),"v2",UUID.randomUUID().toString()) ;
Vertex v3 = new Vertex(gWGraph,UUID.randomUUID(),"v3",UUID.randomUUID().toString()) ;
Vertex v4 = new Vertex(gWGraph,UUID.randomUUID(),"v4",UUID.randomUUID().toString()) ;
Vertex v5 = new Vertex(gWGraph,UUID.randomUUID(),"v5",UUID.randomUUID().toString()) ;
Vertex [] vertices = new Vertex [] {v1,v2,v3,v4,v5};
for (int i = 0; i < vertices.length; i++) {
VertexCreateCommand vcc = new VertexCreateCommand ();
vcc.setVertex(vertices[i]);
vcc.setLocation(new Point(0,0));
vcc.execute();
}
LinkCreateCommand lcc = new LinkCreateCommand ();
lcc.setSource(v1);
lcc.setTarget(v2);
lcc.setGraph(gWGraph);
lcc.setLink(new GWEdge(gWGraph,UUID.randomUUID(), "v1->v2",UUID.randomUUID().toString()));
lcc.execute();
lcc.setSource(v2);
lcc.setTarget(v3);
lcc.setGraph(gWGraph);
lcc.setLink(new GWEdge(gWGraph,UUID.randomUUID(), "v2->v3",UUID.randomUUID().toString()));
lcc.execute();
lcc.setSource(v2);
lcc.setTarget(v4);
lcc.setGraph(gWGraph);
lcc.setLink(new GWEdge(gWGraph,UUID.randomUUID(), "v2->v4",UUID.randomUUID().toString()));
lcc.execute();
lcc.setSource(v4);
lcc.setTarget(v5);
lcc.setGraph(gWGraph);
lcc.setLink(new GWEdge(gWGraph,UUID.randomUUID(), "v4->v5",UUID.randomUUID().toString()));
lcc.execute();
lcc.setSource(v2);
lcc.setTarget(v5);
lcc.setGraph(gWGraph);
lcc.setLink(new GWEdge(gWGraph,UUID.randomUUID(), "v2->v5",UUID.randomUUID().toString()));
lcc.execute();
lcc.setSource(v1);
lcc.setTarget(v4);
lcc.setGraph(gWGraph);
lcc.setLink(new GWEdge(gWGraph,UUID.randomUUID(), "v1->v4",UUID.randomUUID().toString()));
lcc.execute();
return gWGraph;
}
示例12: testEnableDisableSynchronization
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
@Test
public void testEnableDisableSynchronization() throws CoreException, IOException, InterruptedException {
String expectedNewGenerator = "random(vertex_coverage(50))";
PetClinicProject.create (bot,gwproject); // At this step the generator is "random(edge_coverage(100))"
IFile veterinarien = PetClinicProject.getVeterinariensSharedStateImplFile(gwproject);
ICompilationUnit cu = JavaCore.createCompilationUnitFrom(veterinarien);
String oldGenerator = JDTManager.findPathGeneratorInGraphWalkerAnnotation(cu);
SourceHelper.updatePathGenerator(veterinarien, oldGenerator, expectedNewGenerator);
cu = JavaCore.createCompilationUnitFrom(veterinarien);
String newGenerator = JDTManager.findPathGeneratorInGraphWalkerAnnotation(cu);
assertEquals(newGenerator,expectedNewGenerator);
String location = JDTManager.getGW4EGeneratedAnnotationValue(cu,"value");
IPath path = new Path (gwproject).append(location);
IFile graphModel = (IFile)ResourceManager.getResource(path.toString());
IPath buildPolicyPath = ResourceManager.getBuildPoliciesPathForGraphModel(graphModel);
IFile buildPolicyFile = (IFile)ResourceManager.getResource(buildPolicyPath.toString());
PropertyValueCondition condition = new PropertyValueCondition(buildPolicyFile,graphModel.getName(),"random(edge_coverage(100));I;random(vertex_coverage(50));I;");
bot.waitUntil(condition);
GW4EProjectPreference gwpp = new GW4EProjectPreference(bot, gwproject);
GW4EProjectProperties page = gwpp.openPropertiesPage( );
page.toggleSynchronizationButton();
page.ok();
cu = JavaCore.createCompilationUnitFrom(veterinarien);
oldGenerator = JDTManager.findPathGeneratorInGraphWalkerAnnotation(cu);
SourceHelper.updatePathGenerator(veterinarien, oldGenerator, "random(edge_coverage(80))");
cu = JavaCore.createCompilationUnitFrom(veterinarien);
newGenerator = JDTManager.findPathGeneratorInGraphWalkerAnnotation(cu);
// Nothing should have changed
condition = new PropertyValueCondition(buildPolicyFile,graphModel.getName(),"random(edge_coverage(100));I;random(vertex_coverage(50));I;");
bot.waitUntil(condition);
page = gwpp.openPropertiesPage();
page.toggleSynchronizationButton();
page.ok();
cu = JavaCore.createCompilationUnitFrom(veterinarien);
oldGenerator = JDTManager.findPathGeneratorInGraphWalkerAnnotation(cu);
SourceHelper.updatePathGenerator(veterinarien, oldGenerator, "random(edge_coverage(80))");
cu = JavaCore.createCompilationUnitFrom(veterinarien);
newGenerator = JDTManager.findPathGeneratorInGraphWalkerAnnotation(cu);
// should have changed
try {
condition = new PropertyValueCondition(buildPolicyFile,graphModel.getName(),"random(vertex_coverage(50));I;random(edge_coverage(80));I;");
bot.waitUntil(condition);
} catch (TimeoutException e) {
condition = new PropertyValueCondition(buildPolicyFile,graphModel.getName(),"random(edge_coverage(80));I;random(vertex_coverage(50));I;");
bot.waitUntil(condition);
}
}
示例13: execute
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final String filePath = getFilePath();
if (filePath == null) {
return null;
}
final IEditorPart editor = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow()
.getActivePage().getActiveEditor();;
if (editor == null) {
return null;
}
if (editor.isDirty()) {
final IFile file = ResourceUtil.getFile(editor.getEditorInput());
final MessageDialog warningdialog =
new MessageDialog(MarkerActivator.getShell(), "Save Specification", null,
file.getName()
+ " has been modified. You must save file for update the specification. Do you want to save now?",
MessageDialog.WARNING, new String[] {"Yes", "No"}, 0);
if (warningdialog.open() != 0) {
return null;
}
AlloyOtherSolutionReasoning.getInstance().finish();
editor.doSave(new NullProgressMonitor());
}
final String content = getContent(filePath);
if (content == null) {
return null;
}
AlloyUtilities.updateSpec(filePath, content);
try {
TraceManager.get().loadSpec(filePath);
} catch (final TraceException e) {
e.printStackTrace();
}
final MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Status Information",
null, "Specification has been updated.", MessageDialog.INFORMATION, new String[] {"OK"}, 0);
dialog.open();
return null;
}