Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 192081 Details for
Bug 338074
[backport] NatureManager.isNatureEnabled() gives invalid result when called after project import.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
'Ported fix' updated
338074_20110329.txt (text/plain), 14.17 KB, created by
Szymon Brandys
on 2011-03-29 08:01:39 EDT
(
hide
)
Description:
'Ported fix' updated
Filename:
MIME Type:
Creator:
Szymon Brandys
Created:
2011-03-29 08:01:39 EDT
Size:
14.17 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.tests.resources >Index: src/org/eclipse/core/tests/resources/NatureTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/NatureTest.java,v >retrieving revision 1.12 >diff -u -r1.12 NatureTest.java >--- src/org/eclipse/core/tests/resources/NatureTest.java 25 Jan 2008 23:17:21 -0000 1.12 >+++ src/org/eclipse/core/tests/resources/NatureTest.java 29 Mar 2011 12:01:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,8 +10,14 @@ > *******************************************************************************/ > package org.eclipse.core.tests.resources; > >+import java.io.OutputStream; > import junit.framework.Test; > import junit.framework.TestSuite; >+import org.eclipse.core.filesystem.EFS; >+import org.eclipse.core.filesystem.IFileStore; >+import org.eclipse.core.internal.resources.File; >+import org.eclipse.core.internal.resources.Project; >+import org.eclipse.core.internal.utils.FileUtil; > import org.eclipse.core.resources.*; > import org.eclipse.core.runtime.*; > import org.eclipse.core.runtime.jobs.IJobManager; >@@ -259,4 +265,76 @@ > manager.endRule(ws.getRoot()); > } > } >+ >+ >+ >+ /** >+ * Changes project description and parallel checks {@link IProject#isNatureEnabled(String)}, >+ * to check if natures value is cached properly. >+ * >+ * See Bug 338055. >+ * @throws Exception >+ */ >+ public void testBug338055() throws Exception { >+ final boolean finished[] = new boolean[] {false}; >+ final Project project = (Project) ResourcesPlugin.getWorkspace().getRoot().getProject(getUniqueString()); >+ >+ ensureExistsInWorkspace(project, true); >+ >+ new Job("CheckNatureJob") { >+ protected IStatus run(IProgressMonitor monitor) { >+ try { >+ if (finished[0] == false) { >+ if (project.exists() && project.isOpen()) >+ project.isNatureEnabled(NATURE_SIMPLE); >+ schedule(); >+ } >+ } catch (CoreException e) { >+ fail("CheckNatureJob failed", e); >+ } >+ return Status.OK_STATUS; >+ } >+ }.schedule(); >+ >+ try { >+ // Make sure enough time has past to bump file's >+ // timestamp during the copy >+ Thread.sleep(1000); >+ } catch (InterruptedException e) { >+ fail("2.0", e); >+ } >+ >+ IFileStore descStore = ((File) project.getFile(IProjectDescription.DESCRIPTION_FILE_NAME)).getStore(); >+ >+ // create a description with many natures, this will make updating description longer >+ StringBuffer description = new StringBuffer(); >+ description.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><projectDescription><name></name><comment></comment><projects></projects><buildSpec></buildSpec><natures>"); >+ description.append("<nature>" + NATURE_SIMPLE + "</nature>"); >+ for (int i = 0; i < 100; i++) { >+ description.append("<nature>nature" + i + "</nature>"); >+ } >+ description.append("</natures></projectDescription>\n"); >+ >+ // write the description >+ OutputStream output = null; >+ try { >+ output = descStore.openOutputStream(EFS.NONE, getMonitor()); >+ output.write(description.toString().getBytes()); >+ } catch (CoreException e) { >+ fail("1.0"); >+ } finally { >+ FileUtil.safeClose(output); >+ } >+ >+ try { >+ project.refreshLocal(IResource.DEPTH_INFINITE, getMonitor()); >+ } catch (CoreException e) { >+ fail("3.0", e); >+ } >+ >+ finished[0] = true; >+ >+ assertTrue("4.0", project.hasNature(NATURE_SIMPLE)); >+ assertTrue("5.0", project.isNatureEnabled(NATURE_SIMPLE)); >+ } > } >Index: TestFiles/testProject/.project >=================================================================== >RCS file: TestFiles/testProject/.project >diff -N TestFiles/testProject/.project >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ TestFiles/testProject/.project 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,113 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<projectDescription> >+ <name>testProject</name> >+ <comment></comment> >+ <projects> >+ </projects> >+ <buildSpec> >+ </buildSpec> >+ <natures> >+ <nature>org.eclipse.pde.PluginNature</nature> >+ <nature>org.eclipse.jdt.core.javanature</nature> >+ <nature>nature1</nature> >+<nature>nature2</nature> >+<nature>nature3</nature> >+<nature>nature4</nature> >+<nature>nature5</nature> >+<nature>nature6</nature> >+<nature>nature7</nature> >+<nature>nature8</nature> >+<nature>nature9</nature> >+<nature>nature10</nature> >+<nature>nature11</nature> >+<nature>nature12</nature> >+<nature>nature13</nature> >+<nature>nature14</nature> >+<nature>nature15</nature> >+<nature>nature16</nature> >+<nature>nature17</nature> >+<nature>nature18</nature> >+<nature>nature19</nature> >+<nature>nature20</nature> >+<nature>nature21</nature> >+<nature>nature22</nature> >+<nature>nature23</nature> >+<nature>nature24</nature> >+<nature>nature25</nature> >+<nature>nature26</nature> >+<nature>nature27</nature> >+<nature>nature28</nature> >+<nature>nature29</nature> >+<nature>nature30</nature> >+<nature>nature31</nature> >+<nature>nature32</nature> >+<nature>nature33</nature> >+<nature>nature34</nature> >+<nature>nature35</nature> >+<nature>nature36</nature> >+<nature>nature37</nature> >+<nature>nature38</nature> >+<nature>nature39</nature> >+<nature>nature40</nature> >+<nature>nature41</nature> >+<nature>nature42</nature> >+<nature>nature43</nature> >+<nature>nature44</nature> >+<nature>nature45</nature> >+<nature>nature46</nature> >+<nature>nature47</nature> >+<nature>nature48</nature> >+<nature>nature49</nature> >+<nature>nature50</nature> >+<nature>nature51</nature> >+<nature>nature52</nature> >+<nature>nature53</nature> >+<nature>nature54</nature> >+<nature>nature55</nature> >+<nature>nature56</nature> >+<nature>nature57</nature> >+<nature>nature58</nature> >+<nature>nature59</nature> >+<nature>nature60</nature> >+<nature>nature61</nature> >+<nature>nature62</nature> >+<nature>nature63</nature> >+<nature>nature64</nature> >+<nature>nature65</nature> >+<nature>nature66</nature> >+<nature>nature67</nature> >+<nature>nature68</nature> >+<nature>nature69</nature> >+<nature>nature70</nature> >+<nature>nature71</nature> >+<nature>nature72</nature> >+<nature>nature73</nature> >+<nature>nature74</nature> >+<nature>nature75</nature> >+<nature>nature76</nature> >+<nature>nature77</nature> >+<nature>nature78</nature> >+<nature>nature79</nature> >+<nature>nature80</nature> >+<nature>nature81</nature> >+<nature>nature82</nature> >+<nature>nature83</nature> >+<nature>nature84</nature> >+<nature>nature85</nature> >+<nature>nature86</nature> >+<nature>nature87</nature> >+<nature>nature88</nature> >+<nature>nature89</nature> >+<nature>nature90</nature> >+<nature>nature91</nature> >+<nature>nature92</nature> >+<nature>nature93</nature> >+<nature>nature94</nature> >+<nature>nature95</nature> >+<nature>nature96</nature> >+<nature>nature97</nature> >+<nature>nature98</nature> >+<nature>nature99</nature> >+<nature>nature100</nature> >+ </natures> >+</projectDescription> >#P org.eclipse.core.resources >Index: src/org/eclipse/core/internal/resources/NatureManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/NatureManager.java,v >retrieving revision 1.30.2.1 >diff -u -r1.30.2.1 NatureManager.java >--- src/org/eclipse/core/internal/resources/NatureManager.java 20 Sep 2010 11:17:10 -0000 1.30.2.1 >+++ src/org/eclipse/core/internal/resources/NatureManager.java 29 Mar 2011 12:01:24 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -124,7 +124,7 @@ > > public void handleEvent(LifecycleEvent event) { > switch (event.kind) { >- case LifecycleEvent.PRE_PROJECT_CHANGE : >+ case LifecycleEvent.POST_PROJECT_CHANGE : > case LifecycleEvent.PRE_PROJECT_CLOSE : > case LifecycleEvent.PRE_PROJECT_DELETE : > case LifecycleEvent.PRE_PROJECT_MOVE : >Index: src/org/eclipse/core/internal/resources/Project.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Project.java,v >retrieving revision 1.150 >diff -u -r1.150 Project.java >--- src/org/eclipse/core/internal/resources/Project.java 9 May 2008 18:26:14 -0000 1.150 >+++ src/org/eclipse/core/internal/resources/Project.java 29 Mar 2011 12:01:24 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -1012,7 +1012,6 @@ > //see if we have an old .prj file > if (!hadSavedDescription) > hadSavedDescription = workspace.getMetaArea().hasSavedProject(this); >- workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_CHANGE, this)); > workspace.beginOperation(true); > MultiStatus status = basicSetDescription(newDescription, updateFlags); > if (hadSavedDescription && !status.isOK()) >@@ -1030,6 +1029,7 @@ > if (!status.isOK()) > throw new CoreException(status); > } finally { >+ workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.POST_PROJECT_CHANGE, this)); > workspace.endOperation(rule, true, Policy.subMonitorFor(monitor, Policy.endOpWork)); > } > } finally { >@@ -1068,13 +1068,13 @@ > final ISchedulingRule rule = workspace.getRuleFactory().modifyRule(this); > try { > workspace.prepareOperation(rule, monitor); >- workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_CHANGE, this)); > workspace.beginOperation(true); > super.touch(Policy.subMonitorFor(monitor, Policy.opWork)); > } catch (OperationCanceledException e) { > workspace.getWorkManager().operationCanceled(); > throw e; > } finally { >+ workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.POST_PROJECT_CHANGE, this)); > workspace.endOperation(rule, true, Policy.subMonitorFor(monitor, Policy.endOpWork)); > } > } finally { >@@ -1092,7 +1092,6 @@ > return; > ProjectDescription.isReading = true; > try { >- workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_CHANGE, this)); > ProjectDescription description = getLocalManager().read(this, false); > //links can only be created if the project is open > IStatus result = null; >@@ -1102,6 +1101,7 @@ > if (result != null && !result.isOK()) > throw new CoreException(result); > } finally { >+ workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.POST_PROJECT_CHANGE, this)); > ProjectDescription.isReading = false; > } > } >Index: src/org/eclipse/core/internal/resources/ContentDescriptionManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ContentDescriptionManager.java,v >retrieving revision 1.33.2.3 >diff -u -r1.33.2.3 ContentDescriptionManager.java >--- src/org/eclipse/core/internal/resources/ContentDescriptionManager.java 27 Jul 2010 08:46:17 -0000 1.33.2.3 >+++ src/org/eclipse/core/internal/resources/ContentDescriptionManager.java 29 Mar 2011 12:01:24 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2010 IBM Corporation and others. >+ * Copyright (c) 2004, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -456,7 +456,7 @@ > public void handleEvent(LifecycleEvent event) { > //TODO are these the only events we care about? > switch (event.kind) { >- case LifecycleEvent.PRE_PROJECT_CHANGE : >+ case LifecycleEvent.POST_PROJECT_CHANGE : > // if the project changes, its natures may have changed as well (content types may be associated to natures) > case LifecycleEvent.PRE_PROJECT_DELETE : > // if the project gets deleted, we may get confused if it is recreated again (content ids might match) >Index: src/org/eclipse/core/internal/events/LifecycleEvent.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/events/LifecycleEvent.java,v >retrieving revision 1.9 >diff -u -r1.9 LifecycleEvent.java >--- src/org/eclipse/core/internal/events/LifecycleEvent.java 3 Jun 2008 12:34:51 -0000 1.9 >+++ src/org/eclipse/core/internal/events/LifecycleEvent.java 29 Mar 2011 12:01:24 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -20,7 +20,7 @@ > public class LifecycleEvent { > //constants for kinds of internal workspace lifecycle events > public static final int PRE_PROJECT_CLOSE = 0x01; >- public static final int PRE_PROJECT_CHANGE = 0x02; >+ public static final int POST_PROJECT_CHANGE = 0x02; > public static final int PRE_PROJECT_COPY = 0x04; > public static final int PRE_PROJECT_CREATE = 0x08; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 338074
:
191911
| 192081