本文整理匯總了Java中org.eclipse.core.resources.IProject.refreshLocal方法的典型用法代碼示例。如果您正苦於以下問題:Java IProject.refreshLocal方法的具體用法?Java IProject.refreshLocal怎麽用?Java IProject.refreshLocal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IProject
的用法示例。
在下文中一共展示了IProject.refreshLocal方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
@Override
public void run() {
if (GenerationUtils.validate(containerName)) {
Shell shell = Display.getDefault().getActiveShell();
boolean confirm = MessageDialog.openQuestion(shell, "Confirm Create", "Existing Files will be cleared. Do you wish to continue?");
if (confirm) {
wsRoot = ResourcesPlugin.getWorkspace().getRoot();
names = StringUtils.split(containerName, "/");
wsRootRes = wsRoot.findMember(new Path("/" + names[0]));
prj = wsRootRes.getProject();
steps = prj.getFolder("target/Steps");
File root = new File(steps.getLocation().toOSString());
if (root.exists()) {
GenerationUtils.clearCreatedFolders(root);
}
for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
try {
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException e) {
}
}
}
}
}
示例2: getOrCreateGeneratedTestInterfaces
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public static ICompilationUnit[] getOrCreateGeneratedTestInterfaces(IProject project)
throws CoreException, FileNotFoundException {
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
IPath folderForMain = project.getFullPath()
.append(GraphWalkerContextManager.getTargetFolderForTestInterface(project.getName(), true));
IPath folderForTest = project.getFullPath()
.append(GraphWalkerContextManager.getTargetFolderForTestInterface(project.getName(), false));
if (ResourceManager.getResource(folderForMain.toString()) == null
&& ResourceManager.getResource(folderForTest.toString()) == null) {
throw new IllegalStateException(
"No target/generated-sources or target/generated-test-sources folders found");
}
// In main resource folder
ICompilationUnit[] inMain = getExistingGeneratedTestInterfaces(project, true);
// In test resource folder
ICompilationUnit[] inTest = getExistingGeneratedTestInterfaces(project, false);
ICompilationUnit[] ret = new ICompilationUnit[inMain.length+inTest.length];
System.arraycopy(inMain, 0, ret, 0, inMain.length);
System.arraycopy(inTest, 0, ret, inMain.length, inTest.length);
return ret;
}
示例3: testProject
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
@Test
public void testProject() throws CoreException, IOException, PgCodekeeperUIException,
InterruptedException{
try(TempDir tempDir = new TempDir(workspacePath.toPath(), "dbSourceProjectTest")){
File dir = tempDir.get().toFile();
// create empty project in temp dir
IProject project = createProjectInWorkspace(dir.getName());
// populate project with data
new ModelExporter(dir, dbPredefined, ApgdiffConsts.UTF_8).exportFull();
project.refreshLocal(IResource.DEPTH_INFINITE, null);
// testing itself
assertEquals("Project name differs", dir.getName(), project.getName());
performTest(DbSource.fromProject(new PgDbProject(project)));
project.delete(false, true, null);
}
}
示例4: generateDesignProject
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private IProject generateDesignProject(String occieLocation, String designName, String designProjectName,
final IProgressMonitor monitor) throws CoreException, IOException {
// Load the ecore file.
String ecoreLocation = occieLocation.replace(".occie", ".ecore");
URI ecoreURI = URI.createFileURI(ecoreLocation);
// Create a new resource set.
ResourceSet resourceSet = new ResourceSetImpl();
// Load the OCCI resource.
org.eclipse.emf.ecore.resource.Resource resource = resourceSet.getResource(ecoreURI, true);
// Return the first element.
EPackage ePackage = (EPackage) resource.getContents().get(0);
String extensionScheme = Occi2Ecore.convertEcoreNamespace2OcciScheme(ePackage.getNsURI());
// Register the ePackage to avoid an error when trying to open the generated
// .odesign file,
EPackage.Registry.INSTANCE.put(ePackage.getNsURI(), ePackage);
URI occieURI = URI.createFileURI(occieLocation);
/*
* Create design project
*/
IProject project = DesignerGeneratorUtils.genDesignProject(designProjectName, designName, extensionScheme,
new ProgressMonitorDialog(shell));
/*
* Create design model
*/
org.eclipse.cmf.occi.core.gen.design.main.Generate generator = new org.eclipse.cmf.occi.core.gen.design.main.Generate(
occieURI, project.getFolder("description").getLocation().toFile(), new ArrayList<String>());
generator.doGenerate(BasicMonitor.toMonitor(monitor));
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
return project;
}
示例5: getProjectPluginResource
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public IProject getProjectPluginResource(String projectName, IProgressMonitor monitor) throws CoreException {
if (cacheIProject.containsKey(projectName)) return (IProject)cacheIProject.get(projectName);
IProject resourceProject = createProjectPluginResource(projectName);
if (resourceProject.exists()) {
resourceProject.refreshLocal(IResource.DEPTH_INFINITE, monitor);
if (!resourceProject.isOpen())
resourceProject.open(monitor);
}
cacheIProject.put(projectName, resourceProject);
return resourceProject;
}
示例6: createProject
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public static IJavaProject createProject(String name) throws CoreException {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(name);
if (!project.exists()) {
project.create(new NullProgressMonitor());
} else {
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
}
if (!project.isOpen()) {
project.open(new NullProgressMonitor());
}
IFolder binFolder = project.getFolder("bin");
if (!binFolder.exists()) {
createFolder(binFolder, false, true, new NullProgressMonitor());
}
IPath outputLocation = binFolder.getFullPath();
addNatureToProject(project, JavaCore.NATURE_ID, new NullProgressMonitor());
IJavaProject jproject = JavaCore.create(project);
jproject.setOutputLocation(outputLocation, new NullProgressMonitor());
IClasspathEntry[] entries = PreferenceConstants.getDefaultJRELibrary();
jproject.setRawClasspath(entries, new NullProgressMonitor());
return jproject;
}
示例7: refreshProject
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* Refresh project directory corresponding to given {@link DefaultGEFCanvas}.
*
* @param gefCanvas the gef canvas
*/
protected void refreshProject(DefaultGEFCanvas gefCanvas) {
IEditorPart iEditorPart = ((IEditorPart) gefCanvas);
String projectName = ((IFileEditorInput) iEditorPart.getEditorInput()).getFile().getProject().getName();
IProject iProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
try {
iProject.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
logger.error("Error while refreshing the project", e);
}
}
示例8: refreshProject
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
*
* Refresh project directory corresponding to given {@link DefaultGEFCanvas}
*
* @param gefCanvas
*/
protected void refreshProject(DefaultGEFCanvas gefCanvas) {
IEditorPart iEditorPart = ((IEditorPart)gefCanvas);
String projectName = ((IFileEditorInput) iEditorPart.getEditorInput()).getFile().getProject().getName();
IProject iProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
try {
iProject.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
logger.error("Error while refreshing the project", e);
}
}
示例9: generateDesignProject
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private IProject generateDesignProject(String occieLocation, String designName, String designProjectName,
final IProgressMonitor monitor) throws CoreException, IOException {
// Load the ecore file.
String ecoreLocation = occieLocation.replace(".occie", ".ecore");
URI ecoreURI = URI.createFileURI(ecoreLocation);
// Create a new resource set.
ResourceSet resourceSet = new ResourceSetImpl();
// Load the OCCI resource.
org.eclipse.emf.ecore.resource.Resource resource = resourceSet.getResource(ecoreURI, true);
// Return the first element.
EPackage ePackage = (EPackage) resource.getContents().get(0);
String extensionScheme = Occi2Ecore.convertEcoreNamespace2OcciScheme(ePackage.getNsURI());
// Register the ePackage to avoid an error when trying to open the generated
// .odesign file,
EPackage.Registry.INSTANCE.put(ePackage.getNsURI(), ePackage);
URI occieURI = URI.createFileURI(occieLocation);
/*
* Create design project
*/
IProject project = DesignerGeneratorUtils.genDesignProject(designProjectName, designName, extensionScheme,
new ProgressMonitorDialog(shell));
/*
* Create design model
*/
org.eclipse.cmf.occi.core.gen.design.extended.main.Generate generator = new org.eclipse.cmf.occi.core.gen.design.extended.main.Generate(
occieURI, project.getFolder("description").getLocation().toFile(), new ArrayList<String>());
generator.doGenerate(BasicMonitor.toMonitor(monitor));
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
return project;
}
示例10: createManifestN4MFFile
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* @param manifestAdjustments
* before saving the manifest this procedure will be called to allow adjustments to the manifest's
* properties (the ProjectDescription object passed to the procedure will already contain all default
* values). May be <code>null</code> if no adjustments are required.
*/
public static void createManifestN4MFFile(IProject project, String sourceFolder, String outputFolder,
Consumer<ProjectDescription> manifestAdjustments) throws CoreException {
IFile config = project.getFile("manifest.n4mf");
URI uri = URI.createPlatformResourceURI(config.getFullPath().toString(), true);
ProjectDescription projectDesc = N4mfFactory.eINSTANCE.createProjectDescription();
projectDesc.setProjectDependencies(N4mfFactory.eINSTANCE.createProjectDependencies());
projectDesc.setDeclaredVendorId("org.eclipse.n4js");
projectDesc.setVendorName("Eclipse N4JS Project");
projectDesc.setProjectId(project.getName());
projectDesc.setProjectType(ProjectType.LIBRARY);
DeclaredVersion projectVersion = N4mfFactory.eINSTANCE.createDeclaredVersion();
projectVersion.setMajor(0);
projectVersion.setMinor(0);
projectVersion.setMicro(1);
projectDesc.setProjectVersion(projectVersion);
projectDesc.setOutputPath(outputFolder);
SourceFragment sourceProjectPath = N4mfFactory.eINSTANCE.createSourceFragment();
sourceProjectPath.setSourceFragmentType(SourceFragmentType.SOURCE);
sourceProjectPath.getPaths().add(sourceFolder);
projectDesc.getSourceFragment().add(sourceProjectPath);
if (manifestAdjustments != null)
manifestAdjustments.accept(projectDesc);
ResourceSet rs = createResourceSet(project);
Resource res = rs.createResource(uri);
res.getContents().add(projectDesc);
// Workaround to avoid any unnecessary warnings due to empty project dependency block
if (projectDesc.getAllProjectDependencies().isEmpty()) {
projectDesc.setProjectDependencies(null);
}
try {
res.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
project.refreshLocal(IResource.DEPTH_INFINITE, monitor());
waitForAutoBuild();
Assert.assertTrue("manifest.n4mf should have been created", config.exists());
}
示例11: enhanceProject
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
@Override
protected void enhanceProject(final IProject project, final IProgressMonitor monitor) throws CoreException {
final N4MFProjectInfo pi = (N4MFProjectInfo) getProjectInfo();
if (pi.getOutputFolder() == null) {
// Set the default source output folder
pi.setOutputFolder(SRC_GEN);
}
IWorkbench wb = PlatformUI.getWorkbench();
wb.getWorkingSetManager().addToWorkingSets(project, pi.getSelectedWorkingSets());
// IDEBUG-844 project name based string token used for generated files
String projectName = pi.getProjectName();
// create folders
// folders in allFolders are already created by the super class
List<String> otherFolders = Arrays.asList();
for (Iterator<String> iterator = otherFolders.iterator(); iterator.hasNext();) {
String folderName = iterator.next();
IFolder folder = project.getFolder(folderName);
folder.create(false, true, monitor);
}
// create files
String safeProjectName = projectName.replaceAll("\\.", "_").replaceAll("-", "_").trim();
Charset charset = getWorkspaceCharsetOrUtf8();
// Path-Content map of the files to create
Map<String, CharSequence> pathContentMap = new HashMap<>();
// For test projects create a test project greeter if wanted
if (ProjectType.TEST.equals(pi.getProjectType()) && pi.getCreateGreeterFile()) {
pathContentMap.put(modelFolderName + "/" + "Test_" + safeProjectName + ".n4js",
NewN4JSProjectFileTemplates.getSourceFileWithTestGreeter(safeProjectName));
}
// For other projects create the default greeter file
if (!ProjectType.TEST.equals(pi.getProjectType()) && pi.getCreateGreeterFile()) {
pathContentMap.put(modelFolderName + "/" + "GreeterModule_" + safeProjectName + ".n4js",
NewN4JSProjectFileTemplates.getSourceFileWithGreeterClass(projectName, safeProjectName));
}
// create initial files
for (Map.Entry<String, CharSequence> entry : pathContentMap.entrySet()) {
createIfNotExists(project, entry.getKey(), entry.getValue(), charset, monitor);
}
// prepare the manifest
List<String> sources = pi.getSourceFolders();
List<String> tests = pi.getTestSourceFolders();
// If it's a test project use model folder name as test source folder
// and optionally add the source folder as source,
if (ProjectType.TEST.equals(pi.getProjectType())) {
if (pi.getAdditionalSourceFolder()) {
sources.add(SRC_ROOT);
}
tests.add(modelFolderName);
} else { // Otherwise add the model folder name as source folder
sources.add(modelFolderName);
}
// Gather default project dependencies
if (ProjectType.TEST.equals(pi.getProjectType())) {
List<String> projectDependencies = pi.getProjectDependencies();
projectDependencies.addAll(MANGELHAFT_DEPENDENCIES);
}
// Generate manifest content
CharSequence manifestContent = NewN4JSProjectFileTemplates.getManifestContents(pi);
// create manifest
createIfNotExists(project, N4MFConstants.N4MF_MANIFEST, manifestContent, charset, monitor);
project.refreshLocal(DEPTH_INFINITE, monitor);
}
示例12: editPageFunction
import org.eclipse.core.resources.IProject; //導入方法依賴的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() + "'!");
}
}
示例13: editAppComponentTsFile
import org.eclipse.core.resources.IProject; //導入方法依賴的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() + "'!");
}
}
示例14: editPageTsFile
import org.eclipse.core.resources.IProject; //導入方法依賴的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() + "'!");
}
}
示例15: enhanceProject
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
@Override
protected void enhanceProject(final IProject project, final IProgressMonitor monitor) throws CoreException {
IFileSystemAccess2 access = getFileSystemAccess(project, monitor);
initialContents.generateInitialContents(access);
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}