本文整理匯總了Java中org.eclipse.core.resources.IFile.refreshLocal方法的典型用法代碼示例。如果您正苦於以下問題:Java IFile.refreshLocal方法的具體用法?Java IFile.refreshLocal怎麽用?Java IFile.refreshLocal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IFile
的用法示例。
在下文中一共展示了IFile.refreshLocal方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addStringCoupleIfNeeded
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public static void addStringCoupleIfNeeded(IFile classFile, String languageName,
String layerName, IProgressMonitor monitor) throws IOException,
CoreException {
String content = getContent(classFile.getContents(), "UTF8");
final String statement = "res.add(new StringCouple(\"" + languageName
+ "\", \"" + layerName + "\"));";
if (!content.contains(statement)) {
int index = content.lastIndexOf("res.add(new StringCouple(");
if (index >= 0) {
index = index + "res.add(new StringCouple(".length();
while (content.charAt(index) != ';') {
++index;
}
String newContent = content.substring(0, index) + "\n\t\t"
+ statement + "\n"
+ content.substring(index, content.length());
setContent(classFile.getFullPath().toFile(), "UTF8", newContent);
classFile.refreshLocal(1, monitor);
} else {
// TODO notify : add statement manually
}
}
}
示例2: getModelOutputFile
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());
}
示例3: getOutputFile
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public File getOutputFile () throws FileNotFoundException, CoreException, InterruptedException {
IFolder folder = ResourceManager.getWorkspaceRoot().getFolder(containerFullPath);
IFile outfile = folder.getFile(new Path(filename));
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(filename));
if (out.exists()) break;
if (System.currentTimeMillis() > max) {
throw new InterruptedException (out.getFullPath() + " does not exist.");
}
Thread.sleep(500);
}
return ResourceManager.toFile(outfile.getFullPath());
}
示例4: getBuildPoliciesForGraph
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public static IFile getBuildPoliciesForGraph(IFile file, boolean create)
throws CoreException, FileNotFoundException {
String name = PreferenceManager.getBuildPoliciesFileName(file.getProject().getName());
IFolder folder = (IFolder) file.getParent();
IFile policiesFile = folder.getFile(name);
if (policiesFile == null || !policiesFile.exists()) {
if (create) {
byte[] bytes = getDefaultBuildFileComment().getBytes();
InputStream source = new ByteArrayInputStream(bytes);
policiesFile.create(source, IResource.NONE, null);
policiesFile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} else {
throw new FileNotFoundException(folder.getFullPath().append(name).toString());
}
}
return policiesFile;
}
示例5: loadDocument
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public void loadDocument(IFile pluginXmlFile) {
SAXBuilder sxb = new SAXBuilder();
try {
if(!pluginXmlFile.isSynchronized(IResource.DEPTH_ZERO)){
pluginXmlFile.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
}
document = sxb.build(pluginXmlFile.getContents());
root = document.getRootElement();
} catch (Exception e) {
Activator.error(e.getMessage(), e);
}
}
示例6: formatUnitSourceCode
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Format a Unit Source Code
*
* @param testInterface
* @param monitor
* @throws CoreException
*/
@SuppressWarnings("unchecked")
public static void formatUnitSourceCode(IFile file, IProgressMonitor monitor) throws CoreException {
@SuppressWarnings("rawtypes")
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
ICompilationUnit unit = JavaCore.createCompilationUnitFrom(file);
subMonitor.split(50);
ICompilationUnit workingCopy = unit.getWorkingCopy(monitor);
Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7);
options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_7);
options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7);
options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS,
DefaultCodeFormatterConstants.createAlignmentValue(true,
DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE,
DefaultCodeFormatterConstants.INDENT_ON_COLUMN));
final CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(options);
ISourceRange range = unit.getSourceRange();
TextEdit formatEdit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, unit.getSource(),
range.getOffset(), range.getLength(), 0, null);
subMonitor.split(30);
if (formatEdit != null /* && formatEdit.hasChildren()*/) {
workingCopy.applyTextEdit(formatEdit, monitor);
workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null);
workingCopy.commitWorkingCopy(true, null);
workingCopy.discardWorkingCopy();
}
file.refreshLocal(IResource.DEPTH_INFINITE, subMonitor);
subMonitor.split(20);
}
示例7: createBuildPoliciesFile
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Create from scratch a build policy file if it does not exists
*
* @param resource
* @return the build file
* @throws CoreException
* @throws InterruptedException
*/
public static IFile createBuildPoliciesFile(IFile resource, IProgressMonitor monitor)
throws CoreException, InterruptedException {
String buildPolicyFilename = PreferenceManager.getBuildPoliciesFileName(resource.getProject().getName());
IFile buildfile = (IFile) ResourceManager.resfreshFileInContainer(resource.getParent(), buildPolicyFilename);
if (buildfile == null || !buildfile.exists()) {
byte[] bytes = getDefaultBuildFileComment().getBytes();
InputStream source = new ByteArrayInputStream(bytes);
buildfile = resource.getParent().getFile(new Path(buildPolicyFilename));
buildfile.create(source, IResource.NONE, null);
buildfile.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
return buildfile;
}
示例8: refreshParameterFileInProjectExplorer
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
private void refreshParameterFileInProjectExplorer() {
IFile file=ResourcesPlugin.getWorkspace().getRoot().getFile(getParameterFileIPath());
try {
file.refreshLocal(IResource.DEPTH_ZERO, null);
} catch (CoreException e) {
logger.error("Error in refreshing the parameters in file", e);
}
}
示例9: copyFile
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Copies one source file in an Eclipse project to dest.
* If dest already exist, it is silently overridden
* @param project -- project where to copy the file
* @param orig -- file to copy in the project
* @param toLowerCase -- convert all file names to lower case (in windows, case is not important and might be inconsistent)
* @param dest -- path within the project where to put the file
*/
@SuppressWarnings("resource")
private static void copyFile(IProject project, IFolder destPath, File orig, boolean toLowerCase, boolean addHExtension) {
if (checkFileType(orig.getName()) != SOURCE_FILE) {
return;
}
if (! destPath.exists()) {
mkdirs(destPath);
}
try {
String destName;
if (toLowerCase) {
destName = orig.getName().toLowerCase();
}
else {
destName = orig.getName();
}
InputStream source = new ByteArrayInputStream( Files.readAllBytes(orig.toPath()) );
IFile file = destPath.getFile(destName);
if (toLowerCase) {
source = new IncludeToLowerInputStream(source);
}
file.create(source, /*force*/true, Constants.NULL_PROGRESS_MONITOR);
file.refreshLocal(IResource.DEPTH_ZERO, Constants.NULL_PROGRESS_MONITOR);
} catch (IOException e1) {
e1.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
示例10: process
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
@Override
public void process ( final String phase, final IFolder baseDir, final IProgressMonitor monitor, final Map<String, String> properties ) throws Exception
{
if ( phase != null && !"process".equals ( phase ) )
{
return;
}
final String name = makeName ();
final IFolder output = baseDir.getFolder ( new Path ( name ) );
output.create ( true, true, null );
final IFile exporterFile = output.getFile ( "exporter.xml" ); //$NON-NLS-1$
final IFile propFile = output.getFile ( "application.properties" ); //$NON-NLS-1$
final DocumentRoot root = ExporterFactory.eINSTANCE.createDocumentRoot ();
final ConfigurationType cfg = ExporterFactory.eINSTANCE.createConfigurationType ();
root.setConfiguration ( cfg );
final HiveType hive = ExporterFactory.eINSTANCE.createHiveType ();
cfg.getHive ().add ( hive );
hive.setRef ( getHiveId () );
final HiveConfigurationType hiveCfg = ExporterFactory.eINSTANCE.createHiveConfigurationType ();
hive.setConfiguration ( hiveCfg );
addConfiguration ( hiveCfg );
for ( final Endpoint ep : this.driver.getEndpoints () )
{
addEndpoint ( hive, ep );
}
// write exporter file
new ModelWriter ( root ).store ( URI.createPlatformResourceURI ( exporterFile.getFullPath ().toString (), true ) );
exporterFile.refreshLocal ( 1, monitor );
// write application properties
if ( propFile.exists () )
{
propFile.delete ( true, monitor );
}
final Properties p = new Properties ();
fillProperties ( p );
if ( !p.isEmpty () )
{
try (FileOutputStream fos = new FileOutputStream ( propFile.getRawLocation ().toOSString () ))
{
p.store ( fos, "Created by the Eclipse SCADA world generator" );
}
propFile.refreshLocal ( 1, monitor );
}
}
示例11: editPageFunction
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
private void editPageFunction(final UIComponent uic, final String functionMarker, final String propertyName) {
final PageComponent page = uic.getPage();
try {
// Refresh project resources for editor
String projectName = page.getProject().getName();
IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(projectName);
project.refreshLocal(IResource.DEPTH_INFINITE, null);
// Close editor and Reopen it after file has been rewritten
String relativePath = page.getProject().getMobileBuilder().getFunctionTempTsRelativePath(page);
IFile file = project.getFile(relativePath);
closeComponentFileEditor(file);
page.getProject().getMobileBuilder().writeFunctionTempTsFile(page, functionMarker);
file.refreshLocal(IResource.DEPTH_ZERO, null);
// Open file in editor
if (file.exists()) {
IEditorInput input = new ComponentFileEditorInput(file, uic);
if (input != null) {
IEditorDescriptor desc = PlatformUI
.getWorkbench()
.getEditorRegistry()
.getDefaultEditor(file.getName());
IWorkbenchPage activePage = PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage();
String editorId = desc.getId();
IEditorPart editorPart = activePage.openEditor(input, editorId);
editorPart.addPropertyListener(new IPropertyListener() {
boolean isFirstChange = false;
@Override
public void propertyChanged(Object source, int propId) {
if (source instanceof ITextEditor) {
if (propId == IEditorPart.PROP_DIRTY) {
if (!isFirstChange) {
isFirstChange = true;
return;
}
isFirstChange = false;
ITextEditor editor = (ITextEditor)source;
IDocumentProvider dp = editor.getDocumentProvider();
IDocument doc = dp.getDocument(editor.getEditorInput());
String marker = MobileBuilder.getMarker(doc.get(), functionMarker);
String beginMarker = "/*Begin_c8o_" + functionMarker + "*/";
String endMarker = "/*End_c8o_" + functionMarker + "*/";
String content = marker.replace(beginMarker+ System.lineSeparator(), "")
.replace("\t\t"+endMarker, "") // for validator
.replace("\t"+endMarker, ""); // for action
FormatedContent formated = new FormatedContent(content);
MobileUIComponentTreeObject.this.setPropertyValue(propertyName, formated);
}
}
}
});
}
}
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to edit function for page '" + page.getName() + "'!");
}
}
示例12: editAppComponentTsFile
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public void editAppComponentTsFile() {
final ApplicationComponent application = getObject();
try {
// Refresh project resource
String projectName = application.getProject().getName();
IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(projectName);
project.refreshLocal(IResource.DEPTH_INFINITE, null);
// Get filepath of application.component.ts file
String filePath = application.getProject().getMobileBuilder().getTempTsRelativePath(application);
IFile file = project.getFile(filePath);
file.refreshLocal(IResource.DEPTH_ZERO, null);
// Open file in editor
if (file.exists()) {
IEditorInput input = new ComponentFileEditorInput(file, application);
if (input != null) {
IEditorDescriptor desc = PlatformUI
.getWorkbench()
.getEditorRegistry()
.getDefaultEditor(file.getName());
IWorkbenchPage activePage = PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage();
String editorId = desc.getId();
IEditorPart editorPart = activePage.openEditor(input, editorId);
editorPart.addPropertyListener(new IPropertyListener() {
boolean isFirstChange = false;
@Override
public void propertyChanged(Object source, int propId) {
if (source instanceof ITextEditor) {
if (propId == IEditorPart.PROP_DIRTY) {
if (!isFirstChange) {
isFirstChange = true;
return;
}
isFirstChange = false;
ITextEditor editor = (ITextEditor)source;
IDocumentProvider dp = editor.getDocumentProvider();
IDocument doc = dp.getDocument(editor.getEditorInput());
FormatedContent componentScriptContent = new FormatedContent(MobileBuilder.getMarkers(doc.get()));
MobileApplicationComponentTreeObject.this.setPropertyValue("componentScriptContent", componentScriptContent);
}
}
}
});
}
}
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to open typescript file for page '" + application.getName() + "'!");
}
}
示例13: editPageTsFile
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public void editPageTsFile() {
final PageComponent page = (PageComponent)getObject();
try {
// Refresh project resource
String projectName = page.getProject().getName();
IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(projectName);
project.refreshLocal(IResource.DEPTH_INFINITE, null);
// Get filepath of page's temporary TypeScript file
String filePath = page.getProject().getMobileBuilder().getTempTsRelativePath(page);
IFile file = project.getFile(filePath);
file.refreshLocal(IResource.DEPTH_ZERO, null);
// Open file in editor
if (file.exists()) {
IEditorInput input = new ComponentFileEditorInput(file, page);
if (input != null) {
IEditorDescriptor desc = PlatformUI
.getWorkbench()
.getEditorRegistry()
.getDefaultEditor(file.getName());
IWorkbenchPage activePage = PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage();
String editorId = desc.getId();
IEditorPart editorPart = activePage.openEditor(input, editorId);
editorPart.addPropertyListener(new IPropertyListener() {
boolean isFirstChange = false;
@Override
public void propertyChanged(Object source, int propId) {
if (source instanceof ITextEditor) {
if (propId == IEditorPart.PROP_DIRTY) {
if (!isFirstChange) {
isFirstChange = true;
return;
}
isFirstChange = false;
ITextEditor editor = (ITextEditor)source;
IDocumentProvider dp = editor.getDocumentProvider();
IDocument doc = dp.getDocument(editor.getEditorInput());
FormatedContent scriptContent = new FormatedContent(MobileBuilder.getMarkers(doc.get()));
MobilePageComponentTreeObject.this.setPropertyValue("scriptContent", scriptContent);
}
}
}
});
}
}
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to open typescript file for page '" + page.getName() + "'!");
}
}
示例14: testOfflineStandAloneModeWithTimeout
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
@Test
public void testOfflineStandAloneModeWithTimeout() throws Exception {
boolean[] result = new boolean [] {false};
ILogListener listener = new ILogListener() {
@Override
public void logging(IStatus status, String plugin) {
if (status.getMessage().indexOf("Operation cancelled either manually or a timeout occured.")!=-1) {
result[0] = true;
}
}
};
GW4EProject project = new GW4EProject(bot, gwproject);
project.createSimpleProjectWithoutGeneration ();
IFile buildPolicyFile = (IFile) ResourceManager.getResource("gwproject/src/main/resources/com/company/build.policies");
BuildPolicyManager.setPolicies(buildPolicyFile, "Simple.json", "random(never);I", new NullProgressMonitor ());
buildPolicyFile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor ());
FileParameters fp = project.generateForSimpleProject ();
fp.setTargetFilename("SimpleOffLineImpl");
OfflineTestUIPageTest page = walkToToOfflinePage(gwproject,fp);
page.selectTimeout("1");
page.selectStandAloneMode("MyClazz");
page.selectGenerators(new String [] {"random(never)"});
try {
ErrorDialog.AUTOMATED_MODE = true;
ResourceManager.addLogListener(listener);
page.finish();
ICondition condition = new DefaultCondition () {
@Override
public boolean test() throws Exception {
return result[0];
}
@Override
public String getFailureMessage() {
return "Operation not cancelled";
}
};
bot.waitUntil(condition,3 * 6 * SWTBotPreferences.TIMEOUT); //3mn
} finally {
ErrorDialog.AUTOMATED_MODE = false;
ResourceManager.removeLogListener(listener);
}
closeWizard ();
}