Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2010-04-01 18:07:48 -0400
committerStephan Herrmann2010-04-01 18:07:48 -0400
commit02518472f92be6ea86eb5a7cf108c7d9ff95d23d (patch)
tree2188e3d60b3e9aaaae1f1c2ecda02982160ec81d /testplugins/org.eclipse.jdt.ui.tests
parentbe6c0eab70689b72232e96968282f3487e4466b8 (diff)
downloadorg.eclipse.objectteams-02518472f92be6ea86eb5a7cf108c7d9ff95d23d.tar.gz
org.eclipse.objectteams-02518472f92be6ea86eb5a7cf108c7d9ff95d23d.tar.xz
org.eclipse.objectteams-02518472f92be6ea86eb5a7cf108c7d9ff95d23d.zip
initial commit in accordance with CQ 3784
Diffstat (limited to 'testplugins/org.eclipse.jdt.ui.tests')
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/.classpath12
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/.cvsignore1
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/.plugins-path1
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/.project27
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.jdt.core.prefs363
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.jdt.launching.prefs3
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.jdt.ui.prefs12
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.pde.prefs15
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/META-INF/MANIFEST.MF67
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/about.html58
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/activation/org/eclipse/jdt/ui/tests/activation/JavaActivationTest.java109
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/build.properties25
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ChkpiiTests.java370
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/HTMLTidyTest.java223
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ignoreErrorsUnix.txt0
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ignoreErrorsWindows.txt2
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ignoreFiles.txt133
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/cpl-v10.html125
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/ASTRewriteSnippet.java143
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/AddJavaNatureAction.java76
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/AddTestMarkersAction.java141
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/CheckBoxExample.java125
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/DialogFieldExample.java169
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/JavaElementDecorator.java36
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/JavaElementLightweightDecorator.java199
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MultiElementListSelectorExample.java88
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyClasspathContainerInitializer.java54
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyClasspathContainerPage.java61
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyJavadocExportWizardPage.java158
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyProjectCreationWizard.java180
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyProjectCreationWizard2.java205
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyQuickAssistProcessor.java227
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyQuickFixProcessor.java72
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyRenameTypeParticipant.java140
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TabExample.java142
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TestMoveDescriptorAction.java128
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TreeListDialogFieldExample.java129
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TwoPaneElementSelectorExample.java53
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/filters/AFileFilter.java31
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/filters/PureProjectFilter.java47
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/icons/red_dot.gifbin0 -> 151 bytes
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ipl-v10.html252
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/InstancesOfTypeCollector.java90
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/LeakTestCase.java226
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/LeakTestSetup.java43
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/ReferenceInfo.java110
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/example/LeakTestExample.java91
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/FIFOQueue.java91
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/IdentityHashSet.java109
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferenceTracker.java188
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferenceVisitor.java30
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferencedArrayElement.java37
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferencedFieldElement.java38
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferencedObject.java40
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/RootReference.java23
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/JavaLeakTest.java398
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/JavaLeakTestActionDelegate.java49
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/LeakTestSuite.java45
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/SearchLeakTest.java65
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/SearchLeakTestWrapper.java64
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/TextViewerUndoManagerLeakTest.java276
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/UndoManagerLeakTest.java256
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/FileTool.java224
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/JdtPerformanceTestCase.java119
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/PerformanceTestSuite.java25
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/SWTTestProject.java85
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/Accessor.java333
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java479
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/MockupPackageExplorerPart.java33
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OpenTypePerfTest.java235
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OrganizeImportsPerfTest.java126
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerColdPerfTest.java63
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerEmptyPerfTest.java52
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerPerfTest.java110
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWarmPerfTest.java64
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWorkspacePerfTest.java78
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWorkspaceWarmPerfTest.java80
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/TypeHierarchyPerfTest.java139
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/ViewPerformanceTests.java29
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/plugin.properties21
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/plugin.xml272
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java819
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaTestPlugin.java83
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/MixedLineDelimiterDetector.java191
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/OrderedTestSuite.java69
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/StringAsserts.java195
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java633
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptionsSetup.java33
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/HelloWorld.java69
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/JavaTestCase.java89
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/AccessibilityTestPass.java76
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/DialogCheck.java219
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/DisplayHelper.java589
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/FailureDialog.java113
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/FocusTestPass.java74
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/IDialogTestPass.java58
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/SizingTestPass.java82
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/VerifyDialog.java313
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/test.xml145
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/.cvsignore1
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/.classpath7
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/.cvsignore1
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/.project17
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/ant/JUnit4 runAllTests.xml.launch31
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/ant/result/TEST-pack.ATestCase.xml76
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/ant/result/TEST-pack.ATestSuite.xml76
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/ant/result/TEST-pack.AllTests.xml132
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/ant/result/TEST-pack.Failures.xml130
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/ant/result/TESTS-TestSuites.xml703
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/ant/runAllTests.xml46
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/src/pack/ATestCase.java8
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/src/pack/ATestSuite.java11
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/src/pack/AllTests.java11
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/src/pack/Failures.java44
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/xml/ATestCase.xml7
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/xml/ATestSuite.xml9
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/xml/AllTests.xml54
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnit4Tests/xml/Failures.xml159
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/.classpath7
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/.cvsignore1
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/.project17
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/ant/JUnit runAllTests.xml.launch31
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/ant/result/TEST-pack.ATestCase.xml73
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/ant/result/TEST-pack.ATestSuite.xml73
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/ant/result/TEST-pack.AllTests.xml115
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/ant/result/TEST-pack.FailingSuite.xml81
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/ant/result/TEST-pack.Failures.xml113
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/ant/result/TESTS-TestSuites.xml811
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/ant/runAllTests.xml47
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/src/pack/ATestCase.java8
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/src/pack/ATestSuite.java9
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/src/pack/AllTests.java16
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/src/pack/FailingSuite.java26
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/src/pack/Failures.java22
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/xml/ATestCase.xml7
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/xml/ATestCase_testSucceed.xml4
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/xml/ATestSuite.xml9
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/xml/AllTests.xml45
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/xml/FailingSuite.xml22
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/testresources/JUnitWorkspace/JUnitTests/xml/Failures.xml37
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/AbstractTestRunListenerTest.java215
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/AbstractTestRunSessionSerializationTests.java260
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/JUnit3TestFinderTest.java402
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/JUnit4TestFinderTest.java473
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/JUnitJUnitTests.java52
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/JUnitWorkspaceTestSetup.java82
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/LegacyTestRunListener.java102
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/LegacyTestRunListenerTest.java139
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestEnableAssertions.java119
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestPriorization.java387
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestPriorizationSuite.java26
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestPriorizationSuite1.java26
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestPriorizationSuite2.java27
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestRunListenerTest.java273
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestRunListeners.java167
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestRunSessionSerializationTests3.java72
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestRunSessionSerializationTests4.java83
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestTestSearchEngine.java243
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/WrappingSystemTest.java214
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/WrappingUnitTest.java122
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/AutomatedSuite.java78
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/UIInteractiveSuite.java42
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/MockPluginView.java284
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests.java574
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests2.java550
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewDeltaTests.java629
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/TestDelta.java177
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/BuildpathModifierActionEnablementTest.java768
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/BuildpathModifierActionTest.java737
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/buildpath/BuildpathTestSuite.java31
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/callhierarchy/CallHierarchyContentProviderTest.java284
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/callhierarchy/CallHierarchyTestHelper.java377
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ASTNodesInsertTest.java312
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ASTProviderTest.java164
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/AddImportTest.java1237
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/BindingsNameTest.java217
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/CallHierarchyTest.java472
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ClassPathDetectorTest.java344
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/CodeFormatterTest.java280
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/CodeFormatterUtilTest.java602
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/CoreTests.java101
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/HierarchicalASTVisitorTest.java543
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest.java3088
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/IndentManipulationTest.java48
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementLabelsTest.java486
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementPropertyTesterTest.java176
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaModelUtilTest.java332
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/MethodOverrideTest.java502
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/NameProposerTest.java125
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/OverrideTest.java780
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/PartialASTTest.java550
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ProjectTestSetup.java89
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ScopeAnalyzerTest.java945
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/SelectionHistoryTest.java199
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/StringsTest.java37
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TemplateStoreTest.java230
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeHierarchyTest.java302
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeInfoTest.java236
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeRulesTest.java366
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/AddUnimplementedConstructorsTest.java1182
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/AddUnimplementedMethodsTest.java423
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/GenerateConstructorUsingFieldsTest.java761
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/GenerateDelegateMethodsTest.java824
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/GenerateGettersSettersTest.java1001
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/GenerateHashCodeEqualsTest.java1428
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/GenerateToStringTest.java3152
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/SourceActionTests.java45
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/SourceTestCase.java119
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/dialogs/DialogsTest.java193
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/dialogs/DialogsTest2.java118
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/dialogs/PackageExplorerActionEvent.java72
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/dialogs/PreferencesTest.java239
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/dialogs/WizardsTest.java155
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/FatJarExportTests.java1005
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/JarExportTests.java27
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/PlainJarExportTests.java187
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/model/ContentProviderTests.java267
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/model/MockPluginView.java211
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests1.java502
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests2.java358
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests3.java478
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests4.java372
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests5.java271
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/HierarchicalContentProviderTests.java186
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/MockPluginView.java223
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/PackageExplorerShowInTests.java136
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/PackageExplorerTests.java33
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/TestDelta.java151
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/WorkingSetDropAdapterTest.java234
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/preferences/OptionsConfigurationBlockTest.java127
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest.java2650
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java5593
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ChangeNonStaticToStaticTest.java644
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpActionTest.java93
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpAnnotationTest.java237
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java5482
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java7546
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java258
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ContributedQuickFixTest.java170
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertForLoopQuickFixTest.java1999
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertIterableLoopQuickFixTest.java971
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/GetterSetterQuickFixTest.java234
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/JavadocQuickFixTest.java1299
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java7564
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/MarkerResolutionGenerator.java106
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/MarkerResolutionTest.java245
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ModifierCorrectionsQuickFixTest.java3515
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixEnablementTest.java145
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest.java528
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ReorgQuickFixTest.java1076
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ReturnTypeQuickFixTest.java1164
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/SaveParticipantTest.java725
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/SerialVersionQuickFixTest.java465
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/SurroundWithTemplateTest.java1617
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/TypeMismatchQuickFixTests.java2235
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/TypeParameterMismatchTest.java150
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/UnresolvedMethodsQuickFixTest.java4812
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/UnresolvedTypesQuickFixTest.java1499
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/UnresolvedVariablesQuickFixTest.java2617
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/UtilitiesTest.java224
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/FileAdapterTest.java58
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/JUnitSourceSetup.java83
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTest.java516
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTestHelper.java137
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/ParticipantTest.java89
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/SearchTest.java28
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/SearchTestHelper.java79
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/TestParticipant.java82
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/TreeContentProviderTest.java247
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/TreeContentProviderTestWrapper.java72
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/WorkspaceReferenceTest.java40
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/WorkspaceScopeTest.java198
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/ui/internal/compatibility/InternalsNotRemovedTest.java72
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewJavaProjectWizardTest.java309
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewTypeWizardTest.java757
278 files changed, 110100 insertions, 0 deletions
diff --git a/testplugins/org.eclipse.jdt.ui.tests/.classpath b/testplugins/org.eclipse.jdt.ui.tests/.classpath
new file mode 100644
index 000000000..c0bfbd4e5
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/.classpath
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="examples"/>
+ <classpathentry kind="src" path="test plugin"/>
+ <classpathentry kind="src" path="ui"/>
+ <classpathentry kind="src" path="leaks"/>
+ <classpathentry kind="src" path="performance"/>
+ <classpathentry kind="src" path="chkpii"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/testplugins/org.eclipse.jdt.ui.tests/.cvsignore b/testplugins/org.eclipse.jdt.ui.tests/.cvsignore
new file mode 100644
index 000000000..c5e82d745
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/.cvsignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/testplugins/org.eclipse.jdt.ui.tests/.plugins-path b/testplugins/org.eclipse.jdt.ui.tests/.plugins-path
new file mode 100644
index 000000000..36f1716f5
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/.plugins-path
@@ -0,0 +1 @@
+platformPath = file:/d:/workspaces/eclipse-sh1/plugins/
diff --git a/testplugins/org.eclipse.jdt.ui.tests/.project b/testplugins/org.eclipse.jdt.ui.tests/.project
new file mode 100644
index 000000000..beb891add
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/.project
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jdt.ui.tests</name>
+ <comment></comment>
+ <projects></projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
diff --git a/testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.core.resources.prefs b/testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 000000000..e3d075918
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+#Tue Jun 20 14:57:47 CEST 2006
+eclipse.preferences.version=1
+encoding/<project>=ISO-8859-1
diff --git a/testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.jdt.core.prefs b/testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..afa58d5ee
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,363 @@
+#Fri May 01 01:32:07 CEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.cleanOutputFolder=clean
+org.eclipse.jdt.core.builder.duplicateResourceTask=warning
+org.eclipse.jdt.core.builder.invalidClasspath=abort
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
+org.eclipse.jdt.core.circularClasspath=error
+org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
+org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
+org.eclipse.jdt.core.codeComplete.argumentPrefixes=
+org.eclipse.jdt.core.codeComplete.argumentSuffixes=
+org.eclipse.jdt.core.codeComplete.fieldPrefixes=f
+org.eclipse.jdt.core.codeComplete.fieldSuffixes=
+org.eclipse.jdt.core.codeComplete.localPrefixes=
+org.eclipse.jdt.core.codeComplete.localSuffixes=
+org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=fg
+org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=all_standard_tags
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=error
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=error
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=error
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=48
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=1
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=false
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=false
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
+org.eclipse.jdt.core.formatter.comment.line_length=100
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.join_lines_in_comments=true
+org.eclipse.jdt.core.formatter.join_wrapped_lines=false
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=200
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=true
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=true
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=3
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=tab
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.incompatibleJDKLevel=ignore
+org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.jdt.launching.prefs b/testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.jdt.launching.prefs
new file mode 100644
index 000000000..a5ee5cd1a
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.jdt.launching.prefs
@@ -0,0 +1,3 @@
+#Tue Oct 07 11:47:24 CEST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=error
diff --git a/testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.jdt.ui.prefs b/testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 000000000..ee520890d
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,12 @@
+#Tue Jul 15 15:34:15 CEST 2008
+eclipse.preferences.version=1
+formatter_profile=_JDT UI Code Style Conventions
+formatter_settings_version=11
+org.eclipse.jdt.ui.exception.name=e
+org.eclipse.jdt.ui.gettersetter.use.is=true
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=java;javax;sun;com;org;org.apache;org.w3c;org.eclipse;org.eclipse.swt;org.eclipse.core;org.eclipse.core.runtime;org.eclipse.core.resources;org.eclipse.core.filebuffers;org.eclipse.text;org.eclipse.jface;org.eclipse.jface.text;org.eclipse.ui;org.eclipse.ui.workbench.texteditor;org.eclipse.ui.texteditor;org.eclipse.ui.editors;org.eclipse.compare;org.eclipse.debug;org.eclipse.debug.ui;org.eclipse.search;org.eclipse.search2;org.eclipse.ltk;org.eclipse.jdt.core;org.eclipse.jdt.internal;org.eclipse.jdt.launching;org.eclipse.jdt.ui;org.eclipse.jdt.internal.ui;
+org.eclipse.jdt.ui.keywordthis=false
+org.eclipse.jdt.ui.ondemandthreshold=99
+org.eclipse.jdt.ui.overrideannotation=true
+org.eclipse.jdt.ui.staticondemandthreshold=99
diff --git a/testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.pde.prefs b/testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.pde.prefs
new file mode 100644
index 000000000..9665fac70
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/.settings/org.eclipse.pde.prefs
@@ -0,0 +1,15 @@
+#Mon Jan 29 10:51:35 CET 2007
+compilers.incompatible-environment=1
+compilers.p.build=0
+compilers.p.deprecated=1
+compilers.p.missing-packages=0
+compilers.p.no-required-att=0
+compilers.p.not-externalized-att=2
+compilers.p.unknown-attribute=0
+compilers.p.unknown-class=1
+compilers.p.unknown-element=0
+compilers.p.unknown-resource=0
+compilers.p.unresolved-ex-points=0
+compilers.p.unresolved-import=0
+compilers.use-project=true
+eclipse.preferences.version=1
diff --git a/testplugins/org.eclipse.jdt.ui.tests/META-INF/MANIFEST.MF b/testplugins/org.eclipse.jdt.ui.tests/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..6431000cd
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,67 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Plugin.name
+Bundle-SymbolicName: org.eclipse.jdt.ui.tests; singleton:=true
+Bundle-Version: 3.6.0
+Bundle-ClassPath: javauitests.jar
+Bundle-Activator: org.eclipse.jdt.testplugin.JavaTestPlugin
+Bundle-ActivationPolicy: lazy
+Bundle-Vendor: %Plugin.providerName
+Bundle-Localization: plugin
+Export-Package:
+ org.eclipse.jdt.junit.tests;x-internal:=true,
+ org.eclipse.jdt.testplugin;x-internal:=true,
+ org.eclipse.jdt.testplugin.test;x-internal:=true,
+ org.eclipse.jdt.testplugin.util;x-internal:=true,
+ org.eclipse.jdt.ui.examples;x-internal:=true,
+ org.eclipse.jdt.ui.examples.filters;x-internal:=true,
+ org.eclipse.jdt.ui.leaktest;x-internal:=true,
+ org.eclipse.jdt.ui.leaktest.example;x-internal:=true,
+ org.eclipse.jdt.ui.leaktest.reftracker;x-internal:=true,
+ org.eclipse.jdt.ui.tests;x-internal:=true,
+ org.eclipse.jdt.ui.tests.browsing;x-internal:=true,
+ org.eclipse.jdt.ui.tests.buildpath;x-internal:=true,
+ org.eclipse.jdt.ui.tests.callhierarchy;x-internal:=true,
+ org.eclipse.jdt.ui.tests.chkpii;x-internal:=true,
+ org.eclipse.jdt.ui.tests.core;x-internal:=true,
+ org.eclipse.jdt.ui.tests.core.source;x-internal:=true,
+ org.eclipse.jdt.ui.tests.dialogs;x-internal:=true,
+ org.eclipse.jdt.ui.tests.jarexport;x-internal:=true,
+ org.eclipse.jdt.ui.tests.leaks;x-internal:=true,
+ org.eclipse.jdt.ui.tests.model;x-internal:=true,
+ org.eclipse.jdt.ui.tests.packageview;x-internal:=true,
+ org.eclipse.jdt.ui.tests.performance;x-internal:=true,
+ org.eclipse.jdt.ui.tests.performance.views;x-internal:=true,
+ org.eclipse.jdt.ui.tests.preferences;x-internal:=true,
+ org.eclipse.jdt.ui.tests.quickfix;x-internal:=true,
+ org.eclipse.jdt.ui.tests.search;x-internal:=true,
+ org.eclipse.jdt.ui.tests.ui.internal.compatibility;x-internal:=true,
+ org.eclipse.jdt.ui.tests.wizardapi;x-internal:=true
+Require-Bundle:
+ org.eclipse.core.expressions,
+ org.eclipse.core.resources,
+ org.eclipse.core.runtime,
+ org.eclipse.debug.core,
+ org.eclipse.debug.ui,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.core.manipulation,
+ org.eclipse.jdt.junit,
+ org.eclipse.jdt.junit.runtime,
+ org.eclipse.jdt.launching,
+ org.eclipse.jdt.ui;bundle-version="[3.6.0,4.0.0)",
+ org.eclipse.jface.text,
+ org.eclipse.ltk.core.refactoring,
+ org.eclipse.search,
+ org.eclipse.team.core,
+ org.eclipse.team.ui,
+ org.eclipse.test.performance,
+ org.eclipse.ui,
+ org.eclipse.ui.editors,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.navigator,
+ org.eclipse.ui.views,
+ org.eclipse.ui.workbench.texteditor,
+ org.junit;bundle-version="3.8.2",
+ org.eclipse.objectteams.otdt.ui
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/testplugins/org.eclipse.jdt.ui.tests/about.html b/testplugins/org.eclipse.jdt.ui.tests/about.html
new file mode 100644
index 000000000..0237b5466
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/about.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>May 12, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+<h3>Third Party Content</h3>
+
+<p>The Content includes items that have been sourced from third parties as set out below. If you
+did not receive this Content directly from the Eclipse Foundation, the following is provided
+for informational purposes only, and you should look to the Redistributor&rsquo;s license for
+terms and conditions of use.</p>
+
+<h4>JUnit 3.8.1</h4>
+
+<p>The plug-in is accompanied by software developed by JUnit.org. The JUnit 3.8.1 code included with the plug-in includes no modifications.
+Your use of JUnit 3.8.1 in both source and binary code form contained in the plug-in is subject to the terms and conditions of the
+Common Public License Version 1.0 (&quot;CPL&quot;). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
+The source code is located in testresources/junit381-noUI-src.zip.</p>
+
+<p>i) IBM effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;</p>
+
+<p>ii) IBM effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;</p>
+
+<p>iii) IBM states that any provisions which differ from the CPL are offered by that IBM alone and not by any other party.</p>
+
+<h4>JUnit 3.7</h4>
+<p>The plug-in is based on software developed by JUnit.org. Your use of JUnit 3.7 in both source and binary code
+form contained in the plug-in is subject to the terms and conditions of the IBM Public License 1.0 which is available at
+<a href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</a>.
+The source code is located in testresources/junit37-noUI-src.zip.</p>
+
+<p>i) IBM effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;</p>
+<p>ii) IBM effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;</p>
+<p>iii) IBM states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/testplugins/org.eclipse.jdt.ui.tests/activation/org/eclipse/jdt/ui/tests/activation/JavaActivationTest.java b/testplugins/org.eclipse.jdt.ui.tests/activation/org/eclipse/jdt/ui/tests/activation/JavaActivationTest.java
new file mode 100644
index 000000000..10127649a
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/activation/org/eclipse/jdt/ui/tests/activation/JavaActivationTest.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.activation;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+import org.eclipse.core.runtime.IPluginDescriptor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
+import org.eclipse.jdt.testplugin.JavaProjectHelper;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+
+public class JavaActivationTest extends TestCase {
+
+ private IJavaProject project;
+
+ protected void setUp() throws Exception {
+ project= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ }
+
+ protected void tearDown() throws Exception {
+ getPage().closeAllEditors(false);
+ JavaProjectHelper.delete(project);
+ }
+
+ private IWorkbenchPage getPage() {
+ IWorkbench workbench= PlatformUI.getWorkbench();
+ return workbench.getActiveWorkbenchWindow().getActivePage();
+ }
+
+ private ICompilationUnit createTestCU() throws Exception {
+ IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(project, "src");
+ IPackageFragment pack= sourceFolder.createPackageFragment("pack0", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package pack0;\n");
+ buf.append("public class List1 {\n}\n");
+ return pack.createCompilationUnit("List1.java", buf.toString(), false, null);
+ }
+
+ public void testOpenJavaEditor() throws Exception {
+ String[] expectedActivations= {
+ // activated since running tests
+ "org.eclipse.jdt.junit.runtime",
+ "org.eclipse.pde.junit.runtime",
+ "org.eclipse.jdt.ui.tests",
+ "org.junit",
+
+ // expected activations
+ "org.osgi.framework",
+ "org.eclipse.osgi.services",
+ "org.eclipse.osgi.util",
+ "org.eclipse.core.runtime",
+ "org.eclipse.update.configurator",
+ "org.eclipse.compare",
+ "org.eclipse.core.filebuffers",
+ "org.eclipse.core.resources",
+ "org.eclipse.core.runtime.compatibility",
+ "org.eclipse.debug.core",
+ "org.eclipse.debug.ui", // ???
+ "org.eclipse.help",
+ "org.eclipse.jdt.core",
+ "org.eclipse.jdt.ui",
+ "org.eclipse.jface",
+ "org.eclipse.jface.text",
+ "org.eclipse.swt",
+ "org.eclipse.team.core",
+ "org.eclipse.text",
+ "org.eclipse.ui",
+ "org.eclipse.ui.editors",
+ "org.eclipse.ui.externaltools", // ???
+ "org.eclipse.ui.ide",
+ "org.eclipse.ui.views",
+ "org.eclipse.ui.workbench",
+ "org.eclipse.ui.workbench.texteditor",
+ "org.eclipse.update.core",
+ "org.eclipse.update.scheduler" // ???
+ };
+ ICompilationUnit unit= createTestCU();
+ EditorUtility.openInEditor(unit);
+ IPluginDescriptor[] descriptors = Platform.getPluginRegistry().getPluginDescriptors();
+
+ Set set= new HashSet();
+ set.addAll(Arrays.asList(expectedActivations));
+
+ for (int i = 0; i < descriptors.length; i++) {
+ IPluginDescriptor descriptor= descriptors[i];
+ String uniqueIdentifier= descriptor.getUniqueIdentifier();
+ if (descriptor.isPluginActivated())
+ assertTrue ("plugin should not be activated: "+uniqueIdentifier, set.contains(uniqueIdentifier)) ;
+ }
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/build.properties b/testplugins/org.eclipse.jdt.ui.tests/build.properties
new file mode 100644
index 000000000..62ada213a
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/build.properties
@@ -0,0 +1,25 @@
+###############################################################################
+# Copyright (c) 2000, 2009 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
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+bin.includes = plugin.xml,\
+ test.xml,\
+ about.html,\
+ testresources/,\
+ *.jar,\
+ META-INF/,\
+ plugin.properties
+source.javauitests.jar = examples/,\
+ chkpii/,\
+ test plugin/,\
+ ui/,\
+ leaks/,\
+ performance/
+javacWarnings.javauitests.jar=-deadCode
+jre.compilation.profile = J2SE-1.5
diff --git a/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ChkpiiTests.java b/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ChkpiiTests.java
new file mode 100644
index 000000000..5f55182ab
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ChkpiiTests.java
@@ -0,0 +1,370 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.chkpii;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.util.StringTokenizer;
+
+import junit.extensions.ActiveTestSuite;
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import org.eclipse.osgi.service.environment.Constants;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+
+public class ChkpiiTests extends TestCase {
+
+ private String fLogDirectoryName;
+
+ private class FileCategory {
+ private final String fName;
+ protected FileCategory(String name) {
+ fName= name;
+ }
+ public String getOutputFile() {
+ return fLogDirectoryName + fName.toLowerCase() + ".txt";
+ }
+ public String getFilesToTest() {
+ return getPluginDirectory() + getExtension();
+ }
+ protected String getExtension() {
+ return "*." + fName.toLowerCase();
+ }
+
+ public String toString() {
+ return fName.toUpperCase();
+ }
+ }
+ private static class StreamConsumer extends Thread {
+ StringBuffer fStrBuffer;
+ BufferedReader fReader;
+
+
+ public String getContents() {
+ return fStrBuffer.toString();
+ }
+
+ public StreamConsumer(InputStream inputStream) {
+ super();
+ setDaemon(true);
+ try {
+ fReader = new BufferedReader(new InputStreamReader(inputStream, "LATIN1"));
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ fReader = new BufferedReader(new InputStreamReader(inputStream));
+ }
+ fStrBuffer= new StringBuffer();
+ }
+
+ public void run() {
+ try {
+ char[] buf= new char[1024];
+ int count;
+ while (0 < (count = fReader.read(buf))) {
+ fStrBuffer.append(buf, 0, count);
+ }
+ fReader.close();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public void terminate() {
+ interrupt();
+ try {
+ fReader.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ private final FileCategory HTML= new FileCategory("HTML") {
+ protected String getExtension() {
+ return "*.htm*";
+ }
+ };
+ private final FileCategory PROPERTIES= new FileCategory("PROPERTIES");
+ private final FileCategory XML= new FileCategory("XML");
+
+ public static Test suite() {
+ return new ActiveTestSuite(ChkpiiTests.class);
+ }
+
+ public void testHTMLFiles() {
+ assertChkpii(HTML);
+ }
+
+ public void testXMLFiles() {
+ assertChkpii(XML);
+ }
+
+ public void testPropertiesFiles() {
+ assertChkpii(PROPERTIES);
+ }
+
+ private void assertChkpii(FileCategory type) {
+
+ boolean isExecuted= executeChkpiiProcess(type);
+ assertTrue("Could not run chkpii test on " + type + " files. See console for details.", isExecuted); //$NON-NLS-1$
+ StringBuffer buf= new StringBuffer();
+ boolean isValid= checkLogFile(type, buf);
+ assertTrue(buf + "See " + type.getOutputFile() + " for details.", isValid); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ private boolean executeChkpiiProcess(FileCategory type) {
+ Runtime aRuntime= Runtime.getRuntime();
+ String chkpiiString= getChkpiiString(type);
+
+ StreamConsumer err= null;
+ StreamConsumer out= null;
+ Process process= null;
+ try {
+ process= aRuntime.exec(chkpiiString);
+ err= new StreamConsumer(process.getErrorStream());
+ out= new StreamConsumer(process.getInputStream());
+ err.start();
+ out.start();
+ process.waitFor();
+ } catch (IOException e) {
+ e.printStackTrace();
+ return false;
+ } catch (InterruptedException e) {
+ return false;
+ } finally {
+ out.terminate();
+ err.terminate();
+ }
+
+ if (err.getContents().length() > 0 || !new File(type.getOutputFile()).exists()) {
+ System.out.println(out.getContents());
+ System.out.println(err.getContents());
+ System.out.flush();
+ return false;
+ }
+ int res= process.exitValue();
+ System.out.println("ChkpiiTests#" + getName() + "() exit value: " + res);
+ return true;
+ }
+
+ private String getChkpiiString(FileCategory type) {
+ return getExec() + " " + type.getFilesToTest() + " -E -O " + type.getOutputFile() + " -XM @" + getExcludeErrors() + " -X " + getExcludeFile () + " -S -JSQ"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ }
+
+ private String getPluginDirectory() {
+
+ // Get some path inside a plug-in
+ String filePath= toLocation(getClass().getResource("ignoreFiles.txt"));
+
+ StringTokenizer tokenizer= new StringTokenizer(filePath, File.separator);
+
+ String path= "";
+ if (filePath.charAt(0) != File.separatorChar)
+ path= tokenizer.nextToken();
+
+ while (tokenizer.hasMoreTokens()) {
+ String token= tokenizer.nextToken();
+ if (token.equals("org.eclipse.jdt.ui.tests"))
+ break;
+
+ path= path + File.separator + token;
+ }
+ return path + File.separator;
+ }
+
+ private String toLocation(URL platformURL) {
+ File localFile;
+ try {
+ localFile= new File(FileLocator.toFileURL(platformURL).getFile());
+ } catch (IOException e) {
+ e.printStackTrace();
+ return platformURL.getFile();
+ }
+ try {
+ return localFile.getCanonicalPath();
+ } catch (IOException e) {
+ e.printStackTrace();
+ return localFile.getPath();
+ }
+ }
+
+ /**
+ * Method getExcludeFiles.
+ *
+ * @return String
+ */
+ private String getExcludeFile() {
+ return toLocation(getClass().getResource("ignoreFiles.txt"));
+ }
+
+ /**
+ * Method getExec.
+ *
+ * @return String
+ */
+ private String getExec() {
+ return new File("chkpii.exe").getPath(); //$NON-NLS-1$
+ }
+
+ private String getExcludeErrors() {
+
+ String fileName;
+
+ if (Platform.getOS().equals(Constants.OS_WIN32))
+ fileName= "ignoreErrorsWindows.txt"; //$NON-NLS-1$
+ else
+ fileName= "ignoreErrorsUnix.txt"; //$NON-NLS-1$
+
+ return toLocation(getClass().getResource(fileName));
+ }
+
+ /**
+ * Checks if the given log file is valid and states no errors.
+ *
+ * @param type the file category
+ * @param message a string buffer to append error messages to
+ * @return <code>true</code> if there are errors in the log file
+ */
+ private boolean checkLogFile(FileCategory type, StringBuffer message) {
+ String logFilePath= type.getOutputFile();
+ BufferedReader aReader= null;
+ int errors= -1, warnings= -1, notProcessed= -1, endOfSummary= -1;
+ boolean hasFailed= false;
+
+ try {
+ aReader= new BufferedReader(new InputStreamReader(new FileInputStream(logFilePath), Charset.forName("ISO-8859-1")));
+ String aLine= aReader.readLine();
+ while (aLine != null) {
+ if (errors == -1)
+ errors= parseSummary(aLine, "Files Contain Error");
+ if (XML != type && warnings == -1)
+ warnings= parseSummary(aLine, "Files Contain Warnings Only");
+ else if (notProcessed == -1)
+ notProcessed= parseNotProcessedSummary(aLine);
+ else if (endOfSummary == -1)
+ endOfSummary= parseEndOfSummary(aLine);
+ else
+ break;
+
+ aLine= aReader.readLine();
+ }
+
+ if (errors > 0) {
+ message.append("" + errors + " files containing errors\n");
+ hasFailed= true;
+ }
+ if (XML != type && warnings > 0) {
+ message.append("" + errors + " files containing errors\n");
+ hasFailed= true;
+ }
+ if (notProcessed > 0) {
+ message.append("" + notProcessed + " files not found\n");
+ hasFailed= true;
+ }
+ if (endOfSummary != 0) {
+ message.append("Incomplete logfile\n");
+ hasFailed= true;
+ }
+
+ } catch (FileNotFoundException e) {
+ message.append("Could not open log file: " + logFilePath + "\n" + e.getLocalizedMessage() + "\n"); //$NON-NLS-1$
+ hasFailed= true;
+ } catch (IOException e) {
+ message.append("Error reading log file: " + logFilePath + "\n" + e.getLocalizedMessage() + "\n"); //$NON-NLS-1$
+ hasFailed= true;
+ } finally {
+ if (aReader != null) {
+ try {
+ aReader.close();
+ } catch (IOException e) {
+ message.append("Error closing log file: " + logFilePath + "\n" + e.getLocalizedMessage() + "\n"); //$NON-NLS-1$
+ hasFailed= true;
+ }
+ }
+ }
+
+ return !hasFailed;
+ }
+
+ private int parseSummary(String aLine, String parseString) {
+ int index= aLine.indexOf(parseString);
+ if (index == -1)
+ return -1;
+
+ String aString= aLine.substring(0, index).trim();
+ try {
+ return Integer.parseInt(aString);
+ } catch (NumberFormatException e) {
+ return -1;
+ }
+ }
+
+ private int parseNotProcessedSummary(String aLine) {
+ int index= aLine.indexOf("Files Could Not Be Processed"); //$NON-NLS-1$
+ if (index == -1)
+ return -1;
+
+ String aString= aLine.substring(0, index).trim();
+ try {
+ return Integer.parseInt(aString);
+ } catch (NumberFormatException e) {
+ return -1;
+ }
+ }
+
+ private int parseEndOfSummary(String aLine) {
+ int index= aLine.indexOf("End of Listing"); //$NON-NLS-1$
+ if (index == -1)
+ return -1;
+ return 0;
+ }
+
+ /**
+ * Constructor for EmptyDirectoriesTest.
+ *
+ * @param name the test name
+ */
+ public ChkpiiTests(String name) {
+ super(name);
+ fLogDirectoryName= getPluginDirectory() + "chkpiiResults" + File.separator; //$NON-NLS-1$
+ new File(PROPERTIES.getOutputFile()).delete();
+ new File(HTML.getOutputFile()).delete();
+ new File(XML.getOutputFile()).delete();
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ new File(fLogDirectoryName).mkdirs();
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ fLogDirectoryName= null;
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/HTMLTidyTest.java b/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/HTMLTidyTest.java
new file mode 100644
index 000000000..00101887f
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/HTMLTidyTest.java
@@ -0,0 +1,223 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.chkpii;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jdt.testplugin.JavaTestPlugin;
+
+import org.eclipse.core.runtime.FileLocator;
+
+import org.eclipse.jdt.internal.ui.util.StringMatcher;
+
+/**
+ * Runs the 'tidy' command (e.g. from Cygwin) on HTML files in the workspace
+ * and collects HTMLTidy's errors and warnings into /chkpiiResults/tidy.txt
+ *
+ * Note: Currently disabled.
+ */
+public class HTMLTidyTest extends TestCase {
+
+ private static final int TIDY_TIMEOUT= 10000;
+ private static final Pattern EXCLUSION_PATTERN_TABLE_SUMMARY= Pattern.compile("line \\d+ column \\d+ - Warning: <table> lacks \"summary\" attribute");
+
+ private static final Pattern EXCLUSION_PATTERN_EMPTY_TAG= Pattern.compile("line \\d+ column \\d+ - Warning: trimming empty <\\w+>");
+ private static final Pattern EXCLUSION_PATTERN_MALFORMED_URI= Pattern.compile("line \\d+ column \\d+ - Warning: <a> escaping malformed URI reference");
+ private static final Pattern eXCLUSION_PATTERN_SCRIPT_TYPE= Pattern.compile("line \\d+ column \\d+ - Warning: <script> inserting \"type\" attribute");
+ private static final Pattern eXCLUSION_PATTERN_IMG_LACKS_ALT= Pattern.compile("line \\d+ column \\d+ - Warning: <img> lacks \"alt\" attribute");
+
+ private int fworkspacePathLength;
+ private StringMatcher[] fIgnores;
+ private Writer fTidyResults;
+
+ /**
+ * Main method for manual testing of a file or folder selected in the workspace. To run, create
+ * a Java launch configuration with program argument<br>
+ * <code>"${resource_loc}"</code><br>
+ * (including double quotes!).
+ *
+ * @param args 1 argument: Absolute path to a file or folder
+ * @throws Exception if checking fails
+ */
+ public static void main(String[] args) throws Exception {
+ HTMLTidyTest test= new HTMLTidyTest();
+ test.fIgnores= new StringMatcher[0];
+ test.fTidyResults= new OutputStreamWriter(System.out);
+ File file= new File(args[0]);
+ if (file.isDirectory())
+ test.checkFolder(file);
+ else
+ test.checkFile(file);
+ }
+
+ public void testHTML() throws Exception {
+ URL testBundleRoot= JavaTestPlugin.getDefault().getBundle().getEntry("/");
+ URL testBundleFile= FileLocator.toFileURL(testBundleRoot);
+ File hostWorkspace= new File(testBundleFile.getFile()).getParentFile();
+ String workspacePath= hostWorkspace.getAbsolutePath();
+ fworkspacePathLength= workspacePath.length();
+ File chkpiiResults= new File(hostWorkspace, "chkpiiResults");
+ File tidy= new File(chkpiiResults, "tidy.txt");
+ fTidyResults= new OutputStreamWriter(new FileOutputStream(tidy), "UTF-8");
+ String startTime= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
+ fTidyResults.write(getClass().getName() + " started at " + startTime + "\n");
+ fIgnores= getIgnores();
+
+ try {
+ boolean ok= true;
+// ok&= checkFolder(new File(hostWorkspace, "org.eclipse.jdt.doc.user"), tidyResults);
+// ok&= checkFolder(new File(hostWorkspace, "org.eclipse.jdt.doc.isv"), tidyResults);
+// ok&= checkFolder(new File(hostWorkspace, "org.eclipse.platform.doc.user"), tidyResults);
+// ok&= checkFolder(new File(hostWorkspace, "org.eclipse.platform.doc.isv"), tidyResults);
+// ok&= checkFolder(new File(hostWorkspace + "/org.eclipse.jdt.doc.isv/guide"));
+
+ ok&= checkFolder(hostWorkspace);
+
+ assertTrue("See " + tidy.getAbsolutePath(), ok);
+ } finally {
+ fTidyResults.flush();
+ fTidyResults.close();
+ fTidyResults= null;
+ }
+ }
+
+ private StringMatcher[] getIgnores() throws IOException {
+ ArrayList matchers= new ArrayList();
+ InputStream is= getClass().getResourceAsStream("ignoreFiles.txt");
+ BufferedReader reader= new BufferedReader(new InputStreamReader(is));
+ while (reader.ready()) {
+ String line= reader.readLine();
+ if (line.length() > 0) {
+ char first= line.charAt(0);
+ if (line.endsWith("/*"))
+ line= line.substring(0, line.length() - 2); // stops at directory during tree traversal
+ if (first != '/' && first != '*') { // relative matches
+ // emulate CHKPII specification:
+ // matchers.add(new StringMatcher(fWorkspacePath + "/" + line, true, false));
+
+ // emulate actual CHKPII implementation:
+ matchers.add(new StringMatcher("*/" + line, true, false));
+ }
+ matchers.add(new StringMatcher(line, true, false));
+ }
+ }
+ return (StringMatcher[]) matchers.toArray(new StringMatcher[matchers.size()]);
+ }
+
+ private boolean isIgnored(File file) {
+ String relativePath= file.getAbsolutePath().substring(fworkspacePathLength);
+ relativePath= relativePath.replace('\\', '/');
+ for (int i= 0; i < fIgnores.length; i++) {
+ StringMatcher matcher= fIgnores[i];
+ if (matcher.match(relativePath))
+ return true;
+ }
+ return false;
+ }
+
+ private boolean checkFolder(File folder) throws Exception {
+
+ File[] files= folder.listFiles();
+ boolean success= true;
+ for (int i= 0; i < files.length; i++) {
+ File file= files[i];
+ if (isIgnored(file)) {
+// System.out.println("Ignored: " + file.getAbsolutePath() + (file.isDirectory() ? "/*" : ""));
+ continue;
+ }
+ if (isHTMLFile(file)) {
+ success&= checkFile(file);
+ } else if (file.isDirectory()) {
+ success&= checkFolder(file);
+ }
+ }
+ return success;
+ }
+
+ private boolean checkFile(File file) throws Exception {
+ String filePath= file.getAbsolutePath();
+ String command= "tidy -eq \"" + filePath + "\"";
+ final Process process= Runtime.getRuntime().exec(command);
+ long timeout= System.currentTimeMillis() + TIDY_TIMEOUT;
+
+ BufferedReader tidyReader= new BufferedReader(new InputStreamReader(process.getErrorStream()));
+ boolean available= tidyReader.ready();
+ boolean first= true;
+ while (available || System.currentTimeMillis() < timeout) {
+ if (! available) {
+ if (! isAlive(process))
+ break;
+ Thread.sleep(100);
+ } else {
+ while (available) {
+ String line= tidyReader.readLine();
+ if (isRelevant(line)) {
+ if (first) {
+ first= false;
+ fTidyResults.write("\n--- " + filePath +'\n');
+ }
+ fTidyResults.write(line);
+ fTidyResults.write('\n');
+ }
+ available= tidyReader.ready();
+ }
+ }
+ available= tidyReader.ready();
+ if (! available && ! isAlive(process))
+ break;
+ }
+ fTidyResults.flush();
+ try {
+ return process.exitValue() == 0;
+ } catch (IllegalThreadStateException e) {
+ process.destroy();
+ fail("'" + command + "' killed after " + TIDY_TIMEOUT +" ms");
+ return false;
+ }
+ }
+
+ private static boolean isRelevant(String line) {
+ return ! EXCLUSION_PATTERN_TABLE_SUMMARY.matcher(line).matches()
+ && ! EXCLUSION_PATTERN_EMPTY_TAG.matcher(line).matches()
+ && ! EXCLUSION_PATTERN_MALFORMED_URI.matcher(line).matches()
+ && ! eXCLUSION_PATTERN_SCRIPT_TYPE.matcher(line).matches()
+ && ! eXCLUSION_PATTERN_IMG_LACKS_ALT.matcher(line).matches()
+ ;
+ }
+
+ private static boolean isAlive(Process process) {
+ try {
+ process.exitValue();
+ } catch (IllegalThreadStateException e) {
+ return true;
+ }
+ return false;
+ }
+
+ private static boolean isHTMLFile(File file) {
+ String name= file.getName();
+ return (name.endsWith(".html") || name.endsWith(".htm")) && file.isFile();
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ignoreErrorsUnix.txt b/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ignoreErrorsUnix.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ignoreErrorsUnix.txt
diff --git a/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ignoreErrorsWindows.txt b/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ignoreErrorsWindows.txt
new file mode 100644
index 000000000..3a8856178
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ignoreErrorsWindows.txt
@@ -0,0 +1,2 @@
+127
+128
diff --git a/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ignoreFiles.txt b/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ignoreFiles.txt
new file mode 100644
index 000000000..9839ed5e6
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ignoreFiles.txt
@@ -0,0 +1,133 @@
+feature.properties
+feature.xml
+cpl-*.html
+epl-*.html
+ipl-*.html
+license.html
+about.html
+notice.html
+customBuildCallbacks.xml
+buildnotes*.htm
+buildnotes*.html
+*/bin/*
+*/plugin-export/*
+*/.metadata/*
+*/doc_zip/*
+*/scripts/*
+*/icons/*
+
+com.oti.zrh.contextids/*
+com.oti.zrh.eclipse.tools/*
+com.oti.zrh.eclipse.doc.tools-feature/*
+com.oti.zrh.eclipse.tools-updateSite/*
+
+javax.servlet/*
+
+org.eclipse.jdt.ui.tests.refactoring/resources/*
+org.eclipse.jdt.ui/core*extension\org/eclipse/jdt/internal/corext/template/default-codetemplates.xml
+org.eclipse.pde.doc.isv/buildDoc.xml
+org.eclipse.pde.doc.user/buildDoc.xml
+
+org.eclipse.platform.doc.isv/buildDoc.xml
+org.eclipse.jdt.doc.isv/buildDoc.xml
+org.eclipse.jdt.core/*
+org.eclipse.core.resources/build-user.xml
+org.eclipse.core.tests.resources/test.xml
+org.eclipse.tomcat/conf/*
+org.eclipse.ui/plugin.xml
+org.eclipse.platform.source/*
+org.apache.ant/*
+org.eclipse.ant.core/*
+org.eclipse.ant.ui/*
+org.eclipse.help.webapp/*
+org.eclipse.pde.ui/*
+org.eclipse.pde.build/*
+org.eclipse.releng.tools/*
+org.eclipse.sdk.tests-feature/*
+org.eclipse.sdk-feature/*
+org.eclipse.perfmsr.core/*
+org.eclipse.test.performance.ui/*
+org.eclipse.pde.source/*
+org.eclipse.ui.examples.recipeeditor/doc/article.html
+org.eclipse.ui.examples.recipeeditor/templates/templates.xml
+org.eclipse.ant.core/*
+org.eclipse.core.commands/*
+org.eclipse.core.contenttype/*
+org.eclipse.core.filesystem/*
+org.eclipse.core.filesystem.linux.x86/*
+org.eclipse.core.jobs/*
+org.eclipse.core.resources/*
+org.eclipse.core.resources.compatibility/*
+org.eclipse.core.runtime/*
+org.eclipse.core.runtime.compatibility/*
+org.eclipse.core.runtime.compatibility.registry/*
+org.eclipse.core.variables/*
+org.eclipse.core.tests.harness/*
+org.eclipse.debug.core/*
+org.eclipse.debug.ui/*
+org.eclipse.equinox.common/*
+org.eclipse.equinox.preferences/*
+org.eclipse.equinox.registry/*
+org.eclipse.equinox.p2.metadata.generator/*
+org.eclipse.equinox.p2.engine/*
+org.eclipse.equinox.p2.publisher/*
+org.eclipse.help/*
+org.eclipse.help.appserver/*
+org.eclipse.help.base/*
+org.eclipse.help.ui/*
+org.eclipse.jdt.debug/*
+org.eclipse.jdt.debug.ui/*
+org.eclipse.jdt.launching/*
+org.eclipse.jdt.launching.j9/*
+org.eclipse.jface/*
+org.eclipse.osgi/*
+org.eclipse.pde/*
+org.eclipse.pde.core/*
+org.eclipse.sdk/*
+org.eclipse.swt/*
+org.eclipse.swt.examples/*
+org.eclipse.swt.gtk.linux.x86/*
+org.eclipse.swt.win32.win32.x86/*
+org.eclipse.team.core/*
+org.eclipse.team.ui/*
+org.eclipse.ua.tests/*
+org.eclipse.ui.cheatsheets/*
+org.eclipse.ui.console/*
+org.eclipse.ui.forms/*
+org.eclipse.ui.intro/*
+org.eclipse.ui.navigator/*
+org.eclipse.ui.navigator.resources/*
+org.eclipse.ui.tests/*
+org.eclipse.ui.views/*
+org.eclipse.ui.views.properties.tabbed/*
+org.eclipse.ui.workbench/*
+org.eclipse.ui.workbench.compatibility/*
+org.eclipse.update.configurator/*
+org.eclipse.update.core/*
+org.eclipse.update.core.linux/*
+org.eclipse.update.ui/*
+
+com.ibm.icu/*
+javax.servlet.jsp/*
+org.apache.ant/*
+org.apache.commons.el/*
+org.apache.jasper/*
+org.apache.lucene/*
+org.apache.lucene.analysis/*
+org.junit4/*
+org.objectweb.asm/*
+
+www*eclipse.org-eclipse-root/*
+www*eclipse.org-development/*
+www*platform-search/*
+www*platform-UI/*
+platform-releng-home/*
+platform-search-home/*
+platform-text-home/*
+www*platform-text/*
+platform-ui-home/*
+jdt-ui-home/*
+www*jdt-ui/*
+Text*Team*Documents/*
+Eclipse*JDT*Builds/*
+T*JDT-UI*Team*Documents/*
diff --git a/testplugins/org.eclipse.jdt.ui.tests/cpl-v10.html b/testplugins/org.eclipse.jdt.ui.tests/cpl-v10.html
new file mode 100644
index 000000000..ea90e7e70
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/cpl-v10.html
@@ -0,0 +1,125 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<HTML>
+<HEAD>
+<TITLE>Common Public License - v 1.0</TITLE>
+<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
+</HEAD>
+
+<BODY BGCOLOR="#FFFFFF" VLINK="#800000">
+
+
+<P ALIGN="CENTER"><B>Common Public License - v 1.0</B>
+<P><B></B><FONT SIZE="3"></FONT>
+<P><FONT SIZE="3"></FONT><FONT SIZE="2">THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.</FONT>
+<P><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2"><B>1. DEFINITIONS</B></FONT>
+<P><FONT SIZE="2">"Contribution" means:</FONT>
+
+<UL><FONT SIZE="2">a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and<BR CLEAR="LEFT">
+b) in the case of each subsequent Contributor:</FONT></UL>
+
+
+<UL><FONT SIZE="2">i) changes to the Program, and</FONT></UL>
+
+
+<UL><FONT SIZE="2">ii) additions to the Program;</FONT></UL>
+
+
+<UL><FONT SIZE="2">where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. </FONT><FONT SIZE="2">A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. </FONT><FONT SIZE="2">Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. </FONT></UL>
+
+<P><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2">"Contributor" means any person or entity that distributes the Program.</FONT>
+<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2">"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. </FONT>
+<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2"></FONT><FONT SIZE="2">"Program" means the Contributions distributed in accordance with this Agreement.</FONT>
+<P><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2">"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.</FONT>
+<P><FONT SIZE="2"><B></B></FONT>
+<P><FONT SIZE="2"><B>2. GRANT OF RIGHTS</B></FONT>
+
+<UL><FONT SIZE="2"></FONT><FONT SIZE="2">a) </FONT><FONT SIZE="2">Subject to the terms of this Agreement, each Contributor hereby grants</FONT><FONT SIZE="2"> Recipient a non-exclusive, worldwide, royalty-free copyright license to</FONT><FONT SIZE="2" COLOR="#FF0000"> </FONT><FONT SIZE="2">reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.</FONT></UL>
+
+
+<UL><FONT SIZE="2"></FONT></UL>
+
+
+<UL><FONT SIZE="2"></FONT><FONT SIZE="2">b) Subject to the terms of this Agreement, each Contributor hereby grants </FONT><FONT SIZE="2">Recipient a non-exclusive, worldwide,</FONT><FONT SIZE="2" COLOR="#008000"> </FONT><FONT SIZE="2">royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. </FONT></UL>
+
+
+<UL><FONT SIZE="2"></FONT></UL>
+
+
+<UL><FONT SIZE="2">c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.</FONT></UL>
+
+
+<UL><FONT SIZE="2"></FONT></UL>
+
+
+<UL><FONT SIZE="2">d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. </FONT></UL>
+
+
+<UL><FONT SIZE="2"></FONT></UL>
+
+<P><FONT SIZE="2"><B>3. REQUIREMENTS</B></FONT>
+<P><FONT SIZE="2"><B></B>A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:</FONT>
+
+<UL><FONT SIZE="2">a) it complies with the terms and conditions of this Agreement; and</FONT></UL>
+
+
+<UL><FONT SIZE="2">b) its license agreement:</FONT></UL>
+
+
+<UL><FONT SIZE="2">i) effectively disclaims</FONT><FONT SIZE="2"> on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; </FONT></UL>
+
+
+<UL><FONT SIZE="2">ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; </FONT></UL>
+
+
+<UL><FONT SIZE="2">iii)</FONT><FONT SIZE="2"> states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and</FONT></UL>
+
+
+<UL><FONT SIZE="2">iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.</FONT><FONT SIZE="2" COLOR="#0000FF"> </FONT><FONT SIZE="2" COLOR="#FF0000"></FONT></UL>
+
+
+<UL><FONT SIZE="2" COLOR="#FF0000"></FONT><FONT SIZE="2"></FONT></UL>
+
+<P><FONT SIZE="2">When the Program is made available in source code form:</FONT>
+
+<UL><FONT SIZE="2">a) it must be made available under this Agreement; and </FONT></UL>
+
+
+<UL><FONT SIZE="2">b) a copy of this Agreement must be included with each copy of the Program. </FONT></UL>
+
+<P><FONT SIZE="2"></FONT><FONT SIZE="2" COLOR="#0000FF"><STRIKE></STRIKE></FONT>
+<P><FONT SIZE="2" COLOR="#0000FF"><STRIKE></STRIKE></FONT><FONT SIZE="2">Contributors may not remove or alter any copyright notices contained within the Program. </FONT>
+<P><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2">Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. </FONT>
+<P><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2"><B>4. COMMERCIAL DISTRIBUTION</B></FONT>
+<P><FONT SIZE="2">Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.</FONT>
+<P><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2">For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.</FONT>
+<P><FONT SIZE="2"></FONT><FONT SIZE="2" COLOR="#0000FF"></FONT>
+<P><FONT SIZE="2" COLOR="#0000FF"></FONT><FONT SIZE="2"><B>5. NO WARRANTY</B></FONT>
+<P><FONT SIZE="2">EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is</FONT><FONT SIZE="2"> solely responsible for determining the appropriateness of using and distributing </FONT><FONT SIZE="2">the Program</FONT><FONT SIZE="2"> and assumes all risks associated with its exercise of rights under this Agreement</FONT><FONT SIZE="2">, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, </FONT><FONT SIZE="2">programs or equipment, and unavailability or interruption of operations</FONT><FONT SIZE="2">. </FONT><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2"></FONT><FONT SIZE="2"><B>6. DISCLAIMER OF LIABILITY</B></FONT>
+<P><FONT SIZE="2"></FONT><FONT SIZE="2">EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES </FONT><FONT SIZE="2">(INCLUDING WITHOUT LIMITATION LOST PROFITS),</FONT><FONT SIZE="2"> HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</FONT>
+<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2"><B>7. GENERAL</B></FONT>
+<P><FONT SIZE="2"></FONT><FONT SIZE="2">If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.</FONT>
+<P><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2">If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. </FONT><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2">All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. </FONT><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2"></FONT><FONT SIZE="2">Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to </FONT><FONT SIZE="2">publish new versions (including revisions) of this Agreement from time to </FONT><FONT SIZE="2">time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. </FONT><FONT SIZE="2">Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new </FONT><FONT SIZE="2">version. </FONT><FONT SIZE="2">Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, </FONT><FONT SIZE="2">by implication, estoppel or otherwise</FONT><FONT SIZE="2">.</FONT><FONT SIZE="2"> All rights in the Program not expressly granted under this Agreement are reserved.</FONT>
+<P><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2">This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.</FONT>
+<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
+<P><FONT SIZE="2"></FONT>
+
+</BODY>
+
+</HTML> \ No newline at end of file
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/ASTRewriteSnippet.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/ASTRewriteSnippet.java
new file mode 100644
index 000000000..bb7ea417d
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/ASTRewriteSnippet.java
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.text.edits.TextEdit;
+
+import org.eclipse.jface.text.Document;
+
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTParser;
+import org.eclipse.jdt.core.dom.Block;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.MethodInvocation;
+import org.eclipse.jdt.core.dom.Statement;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
+import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
+import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
+
+import org.eclipse.jdt.launching.JavaRuntime;
+
+public class ASTRewriteSnippet extends TestCase {
+
+ public void testASTRewriteExample() throws Exception {
+ // create a new project
+ IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject("Test");
+ project.create(null);
+ project.open(null);
+ try {
+ // set the Java nature and Java build path
+ IProjectDescription description = project.getDescription();
+ description.setNatureIds(new String[] { JavaCore.NATURE_ID } );
+ project.setDescription(description, null);
+
+ IJavaProject javaProject= JavaCore.create(project);
+
+ // build path is: project as source folder and JRE container
+ IClasspathEntry[] cpentry= new IClasspathEntry[] {
+ JavaCore.newSourceEntry(javaProject.getPath()),
+ JavaRuntime.getDefaultJREContainerEntry()
+ };
+ javaProject.setRawClasspath(cpentry, javaProject.getPath(), null);
+ Map options= new HashMap();
+ options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
+ javaProject.setOptions(options);
+
+ // create a test file
+ IPackageFragmentRoot root= javaProject.getPackageFragmentRoot(project);
+ IPackageFragment pack1= root.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public void foo(int i) {\n");
+ buf.append(" while (--i > 0) {\n");
+ buf.append(" System.beep();\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
+
+ // create an AST
+ ASTParser parser= ASTParser.newParser(AST.JLS3);
+ parser.setSource(cu);
+ parser.setResolveBindings(false);
+ CompilationUnit astRoot= (CompilationUnit) parser.createAST(null);
+ AST ast= astRoot.getAST();
+
+ // create the descriptive ast rewriter
+ ASTRewrite rewrite= ASTRewrite.create(ast);
+
+ // get the block node that contains the statements in the method body
+ TypeDeclaration typeDecl = (TypeDeclaration) astRoot.types().get(0);
+ MethodDeclaration methodDecl= typeDecl.getMethods()[0];
+ Block block= methodDecl.getBody();
+
+ // create new statements to insert
+ MethodInvocation newInv1= ast.newMethodInvocation();
+ newInv1.setName(ast.newSimpleName("bar1"));
+ Statement newStatement1= ast.newExpressionStatement(newInv1);
+
+ MethodInvocation newInv2= ast.newMethodInvocation();
+ newInv2.setName(ast.newSimpleName("bar2"));
+ Statement newStatement2= ast.newExpressionStatement(newInv2);
+
+ // describe that the first node is inserted as first statement in block, the other one as last statement
+ // note: AST is not modified by this
+ ListRewrite listRewrite= rewrite.getListRewrite(block, Block.STATEMENTS_PROPERTY);
+ listRewrite.insertFirst(newStatement1, null);
+ listRewrite.insertLast(newStatement2, null);
+
+ // evaluate the text edits corresponding to the described changes. AST and CU still unmodified.
+ TextEdit res= rewrite.rewriteAST();
+
+ // apply the text edits to the compilation unit
+ Document document= new Document(cu.getSource());
+ res.apply(document);
+ cu.getBuffer().setContents(document.get());
+
+ // test result
+ String preview= cu.getSource();
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public void foo(int i) {\n");
+ buf.append(" bar1();\n");
+ buf.append(" while (--i > 0) {\n");
+ buf.append(" System.beep();\n");
+ buf.append(" }\n");
+ buf.append(" bar2();\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ assertEquals(preview, buf.toString());
+ } finally {
+ project.delete(true, null);
+ }
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/AddJavaNatureAction.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/AddJavaNatureAction.java
new file mode 100644
index 000000000..8bfbc00c8
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/AddJavaNatureAction.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+import org.eclipse.jdt.testplugin.JavaTestPlugin;
+
+import org.eclipse.core.resources.IProject;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import org.eclipse.ui.IActionDelegate;
+
+import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathsBlock;
+
+/** In plugin.xml:
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IProject"
+ id="org.eclipse.jdt.ui.examples.AddJavaNatureAction">
+ <action
+ label="Add Java Nature (jdt.ui.tests)"
+ tooltip="Add Java Nature"
+ class="org.eclipse.jdt.ui.examples.AddJavaNatureAction"
+ menubarPath="AddJavaNauture"
+ enablesFor="1"
+ id="addJavaNature">
+ </action>
+ </objectContribution>
+ </extension>
+ */
+
+public class AddJavaNatureAction extends Action implements IActionDelegate {
+
+ private IProject fProject;
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ try {
+ if (fProject != null) {
+ BuildPathsBlock.addJavaNature(fProject, null);
+ }
+ } catch (Exception e) {
+ JavaTestPlugin.log(e);
+ }
+
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ fProject= null;
+ if (selection instanceof IStructuredSelection) {
+ Object object= ((IStructuredSelection) selection).getFirstElement();
+ if (object instanceof IProject) {
+ fProject= (IProject) object;
+
+ }
+ }
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/AddTestMarkersAction.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/AddTestMarkersAction.java
new file mode 100644
index 000000000..392fe06a9
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/AddTestMarkersAction.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+import java.util.HashMap;
+
+import org.eclipse.jdt.testplugin.JavaTestPlugin;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.core.resources.IMarker;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import org.eclipse.ui.IActionDelegate;
+
+import org.eclipse.ui.texteditor.MarkerUtilities;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.ToolFactory;
+import org.eclipse.jdt.core.compiler.IScanner;
+import org.eclipse.jdt.core.compiler.ITerminalSymbols;
+
+import org.eclipse.jdt.ui.JavaUI;
+
+/** In plugin.xml:
+ <extension
+ id="testmarker"
+ name="jdt-test-problem"
+ point="org.eclipse.core.resources.markers">
+ <super
+ type="org.eclipse.core.resources.problemmarker">
+ </super>
+ </extension>
+ <extension
+ point="org.eclipse.ui.ide.markerResolution">
+ <markerResolutionGenerator
+ markerType="org.eclipse.jdt.ui.tests.testmarker"
+ class="org.eclipse.jdt.ui.tests.quickfix.MarkerResolutionGenerator">
+ </markerResolutionGenerator>
+ </extension>
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ objectClass="org.eclipse.jdt.core.ICompilationUnit"
+ id="org.eclipse.jdt.ui.examples.AddTestMarkersAction">
+ <action
+ label="%AddTestMarkersAction.label"
+ tooltip="%AddTestMarkersAction.tooltip"
+ class="org.eclipse.jdt.ui.examples.AddTestMarkersAction"
+ menubarPath="AddTestMarkers"
+ enablesFor="1"
+ id="addTestmarkers">
+ </action>
+ </objectContribution>
+ </extension>
+ */
+
+public class AddTestMarkersAction extends Action implements IActionDelegate {
+
+ public static final String MARKER_TYPE= "org.eclipse.jdt.ui.tests.testmarker";
+
+ private ICompilationUnit fCompilationUnit;
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ try {
+ JavaUI.openInEditor(fCompilationUnit);
+
+ IScanner scanner= ToolFactory.createScanner(true, false, false, true);
+ scanner.setSource(fCompilationUnit.getSource().toCharArray());
+
+ int count= 0;
+ int tok;
+ do {
+ tok= scanner.getNextToken();
+ if (isComment(tok)) {
+ int start= scanner.getCurrentTokenStartPosition();
+ int end= scanner.getCurrentTokenEndPosition() + 1;
+ int line= scanner.getLineNumber(start);
+ createMarker(fCompilationUnit, line, start, end - start);
+ count++;
+ }
+ } while (tok != ITerminalSymbols.TokenNameEOF);
+
+ MessageDialog.openInformation(null, "Test Markers", count + " markers added");
+ } catch (Exception e) {
+ JavaTestPlugin.log(e);
+ }
+
+ }
+
+ public static boolean isComment(int token) {
+ return token == ITerminalSymbols.TokenNameCOMMENT_BLOCK || token == ITerminalSymbols.TokenNameCOMMENT_JAVADOC
+ || token == ITerminalSymbols.TokenNameCOMMENT_LINE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ fCompilationUnit= null;
+ if (selection instanceof IStructuredSelection) {
+ Object object= ((IStructuredSelection) selection).getFirstElement();
+ if (object instanceof ICompilationUnit) {
+ fCompilationUnit= (ICompilationUnit) object;
+
+ }
+ }
+ }
+
+
+ private void createMarker(ICompilationUnit cu, int line, int offset, int len) throws CoreException {
+ HashMap map= new HashMap();
+ map.put(IMarker.LOCATION, cu.getElementName());
+ map.put(IMarker.MESSAGE, "Test marker");
+ map.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
+ map.put(IMarker.LINE_NUMBER, new Integer(line));
+ map.put(IMarker.CHAR_START, new Integer(offset));
+ map.put(IMarker.CHAR_END, new Integer(offset + len));
+
+ MarkerUtilities.createMarker(cu.getResource(), map, MARKER_TYPE);
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/CheckBoxExample.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/CheckBoxExample.java
new file mode 100644
index 000000000..692f7415e
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/CheckBoxExample.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+
+import java.util.List;
+import java.util.Random;
+
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.jface.viewers.LabelProvider;
+
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField;
+
+
+public class CheckBoxExample {
+ private Shell fShell;
+
+ public CheckBoxExample() {
+ }
+
+ public CheckBoxExample close () {
+ if ((fShell != null) && (!fShell.isDisposed ())) fShell.dispose ();
+ fShell= null;
+ return this;
+ }
+
+ public CheckBoxExample open () {
+ fShell= new Shell ();
+ fShell.setText("Message Dialog Example");
+ fShell.setLayout(new GridLayout());
+
+ Adapter adapter= new Adapter();
+
+
+
+ String[] addButtons= new String[] {
+ /* 0 */ "Add1",
+ /* 1 */ "Check 0",
+ /* 2 */ "Print",
+ /* 3 */ null,
+ /* 4 */ "Check All",
+ /* 5 */ "Uncheck All",
+ /* 6 */ null,
+ /* 7 */ "Remove"
+ };
+ CheckedListDialogField list= new CheckedListDialogField(adapter, addButtons, new LabelProvider());
+ list.setCheckAllButtonIndex(4);
+ list.setUncheckAllButtonIndex(5);
+ list.setRemoveButtonIndex(7);
+ list.setLabelText("List: ");
+
+ LayoutUtil.doDefaultLayout(fShell, new DialogField[] { list }, false);
+
+ fShell.setSize(400,500);
+ fShell.open ();
+ return this;
+ }
+
+ private static Random fgRandom= new Random();
+
+ private class Adapter implements IStringButtonAdapter, IDialogFieldListener, IListAdapter {
+
+ // -------- IStringButtonAdapter
+ public void changeControlPressed(DialogField field) {
+ }
+
+ // -------- IListAdapter
+ public void customButtonPressed(ListDialogField field, int index) {
+ if (field instanceof CheckedListDialogField) {
+ CheckedListDialogField list= (CheckedListDialogField)field;
+ if (index == 0) {
+ list.addElement("element-" + (fgRandom.nextInt() % 1000));
+ } else if (index == 2) {
+ System.out.println("---- printing all");
+ List checked= list.getCheckedElements();
+ for (int i= 0; i < checked.size(); i++) {
+ System.out.println(checked.get(i).toString());
+ }
+ } else {
+ list.setChecked(list.getElement(0), true);
+ }
+ }
+ }
+
+ public void selectionChanged(ListDialogField field) {}
+
+ // -------- IDialogFieldListener
+ public void dialogFieldChanged(DialogField field) {
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#doubleClicked(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField)
+ */
+ public void doubleClicked(ListDialogField field) {
+ }
+ }
+
+ public CheckBoxExample run () {
+ Display display= fShell.getDisplay ();
+ while (!fShell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ return this;
+ }
+
+ public static void main(java.lang.String[] args) {
+ new CheckBoxExample().open().run().close();
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/DialogFieldExample.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/DialogFieldExample.java
new file mode 100644
index 000000000..e1d7d16bb
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/DialogFieldExample.java
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+
+import java.util.Random;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogFieldGroup;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
+
+
+public class DialogFieldExample {
+ private Shell fShell;
+
+ public DialogFieldExample() {
+ }
+
+ public DialogFieldExample close () {
+ if ((fShell != null) && (!fShell.isDisposed ())) fShell.dispose ();
+ fShell= null;
+ return this;
+ }
+
+ private class MylabelProvider extends LabelProvider implements ITableLabelProvider {
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ */
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ */
+ public String getColumnText(Object element, int columnIndex) {
+ if (columnIndex == 0) {
+ return element.toString();
+ } else {
+ return "" + columnIndex;
+ }
+ }
+ }
+
+
+ public DialogFieldExample open () {
+ fShell= new Shell ();
+ fShell.setText("Message Dialog Example");
+ fShell.setLayout(new GridLayout());
+
+ Adapter adapter= new Adapter();
+
+ StringButtonDialogField string1= new StringButtonDialogField(adapter);
+ string1.setLabelText("String1: ");
+ string1.setText("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
+
+ StringButtonDialogField stringbutton= new StringButtonDialogField(adapter);
+ stringbutton.setLabelText("StringButton: ");
+ stringbutton.setButtonLabel("Click");
+ stringbutton.setText("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
+
+
+ String[] addButtons= new String[] {
+ /* 0 */ "Add1",
+ /* 1 */ "Add2",
+ /* 2 */ null,
+ /* 3 */ "Up",
+ /* 4 */ "Down",
+ /* 5 */ null,
+ /* 6 */ "Remove"
+ };
+ String[] columnHeaders= new String[] { "Name", "Number" };
+
+
+ ListDialogField list= new ListDialogField(adapter, addButtons, new MylabelProvider());
+ list.setUpButtonIndex(3);
+ list.setDownButtonIndex(4);
+ list.setRemoveButtonIndex(6);
+ list.setLabelText("List: ");
+
+ list.setTableColumns(new ListDialogField.ColumnsDescription(columnHeaders, true));
+
+ for (int i= 0; i < 30; i++) {
+ list.addElement(i + "firstxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
+ }
+
+ SelectionButtonDialogField selButton= new SelectionButtonDialogField(SWT.PUSH);
+ selButton.setLabelText("Press Button");
+
+ String[] radioButtons1= new String[] { "Option One", "Option Two", "Option Three" };
+ SelectionButtonDialogFieldGroup rdgroup1= new SelectionButtonDialogFieldGroup(SWT.RADIO, radioButtons1, 3, 0);
+ rdgroup1.setLabelText("Radio Button Group");
+
+ String[] radioButtons2= new String[] { "Option One", "Option Two", "Option Three" };
+ SelectionButtonDialogFieldGroup rdgroup2= new SelectionButtonDialogFieldGroup(SWT.CHECK, radioButtons2, 3);
+ rdgroup2.setLabelText("Radio Button Group 2");
+
+ LayoutUtil.doDefaultLayout(fShell, new DialogField[] { string1, rdgroup2, stringbutton, selButton, list, rdgroup1 }, false);
+
+ ((GridData)string1.getTextControl(null).getLayoutData()).widthHint= 100;
+ ((GridData)stringbutton.getTextControl(null).getLayoutData()).widthHint= 100;
+
+ fShell.setSize(fShell.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ fShell.open ();
+ return this;
+ }
+
+ private static Random fgRandom= new Random();
+
+ private class Adapter implements IStringButtonAdapter, IDialogFieldListener, IListAdapter {
+
+ // -------- IStringButtonAdapter
+ public void changeControlPressed(DialogField field) {
+ }
+
+ // -------- IListAdapter
+ public void customButtonPressed(ListDialogField field, int index) {
+ if (field != null) {
+ field.addElement("elementxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-" + fgRandom.nextInt());
+ }
+ }
+
+ public void selectionChanged(ListDialogField field) {}
+
+ // -------- IDialogFieldListener
+ public void dialogFieldChanged(DialogField field) {
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#doubleClicked(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField)
+ */
+ public void doubleClicked(ListDialogField field) {
+ }
+ }
+
+ public DialogFieldExample run () {
+ Display display= fShell.getDisplay ();
+ while (!fShell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ return this;
+ }
+
+ public static void main(java.lang.String[] args) {
+ new DialogFieldExample().open().run().close();
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/JavaElementDecorator.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/JavaElementDecorator.java
new file mode 100644
index 000000000..519a5c88f
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/JavaElementDecorator.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.LabelProvider;
+
+/**
+ * Allows to test decorators for Java elements
+ */
+public class JavaElementDecorator extends LabelProvider implements ILabelDecorator {
+
+ /*
+ * @see ILabelDecorator#decorateImage(Image, Object)
+ */
+ public Image decorateImage(Image image, Object element) {
+ return null;
+ }
+
+ /*
+ * @see ILabelDecorator#decorateText(String, Object)
+ */
+ public String decorateText(String text, Object element) {
+ return text + "*";
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/JavaElementLightweightDecorator.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/JavaElementLightweightDecorator.java
new file mode 100644
index 000000000..c398d70dc
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/JavaElementLightweightDecorator.java
@@ -0,0 +1,199 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.IFileBuffer;
+import org.eclipse.core.filebuffers.IFileBufferListener;
+import org.eclipse.core.filebuffers.LocationKind;
+
+import org.eclipse.jface.resource.FontRegistry;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.progress.UIJob;
+
+import org.eclipse.jdt.core.IClassFile;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+
+/**
+ *
+ */
+public class JavaElementLightweightDecorator extends LabelProvider implements ILightweightLabelDecorator {
+
+ private class FileBufferListener implements IFileBufferListener {
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filebuffers.IFileBufferListener#bufferCreated(org.eclipse.core.filebuffers.IFileBuffer)
+ */
+ public void bufferCreated(IFileBuffer buffer) {
+ if (buffer.getLocation() != null)
+ update(buffer.getLocation());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filebuffers.IFileBufferListener#bufferDisposed(org.eclipse.core.filebuffers.IFileBuffer)
+ */
+ public void bufferDisposed(IFileBuffer buffer) {
+ if (buffer.getLocation() != null)
+ update(buffer.getLocation());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filebuffers.IFileBufferListener#bufferContentAboutToBeReplaced(org.eclipse.core.filebuffers.IFileBuffer)
+ */
+ public void bufferContentAboutToBeReplaced(IFileBuffer buffer) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filebuffers.IFileBufferListener#bufferContentReplaced(org.eclipse.core.filebuffers.IFileBuffer)
+ */
+ public void bufferContentReplaced(IFileBuffer buffer) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filebuffers.IFileBufferListener#stateChanging(org.eclipse.core.filebuffers.IFileBuffer)
+ */
+ public void stateChanging(IFileBuffer buffer) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filebuffers.IFileBufferListener#dirtyStateChanged(org.eclipse.core.filebuffers.IFileBuffer, boolean)
+ */
+ public void dirtyStateChanged(IFileBuffer buffer, boolean isDirty) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filebuffers.IFileBufferListener#stateValidationChanged(org.eclipse.core.filebuffers.IFileBuffer, boolean)
+ */
+ public void stateValidationChanged(IFileBuffer buffer, boolean isStateValidated) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filebuffers.IFileBufferListener#underlyingFileMoved(org.eclipse.core.filebuffers.IFileBuffer, org.eclipse.core.runtime.IPath)
+ */
+ public void underlyingFileMoved(IFileBuffer buffer, IPath path) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filebuffers.IFileBufferListener#underlyingFileDeleted(org.eclipse.core.filebuffers.IFileBuffer)
+ */
+ public void underlyingFileDeleted(IFileBuffer buffer) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.filebuffers.IFileBufferListener#stateChangeFailed(org.eclipse.core.filebuffers.IFileBuffer)
+ */
+ public void stateChangeFailed(IFileBuffer buffer) {}
+ }
+
+ private Color fColor;
+ private Font fBold;
+ private FileBufferListener fListener;
+
+ private UIJob fNotifierJob;
+
+ private Set fChangedResources;
+
+ public JavaElementLightweightDecorator() {
+ final FontRegistry fontRegistry= PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry();
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ fColor= new Color(Display.getDefault(), 100, 100, 100);
+ fBold= fontRegistry.getBold(JFaceResources.DEFAULT_FONT);
+ }
+ });
+ fListener= new FileBufferListener();
+ FileBuffers.getTextFileBufferManager().addFileBufferListener(fListener);
+
+ fChangedResources= new HashSet();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration)
+ */
+ public void decorate(Object element, IDecoration decoration) {
+ IPath path= null;
+
+ if (element instanceof IResource) {
+ path= ((IResource) element).getFullPath();
+ } else if (element instanceof IClassFile || element instanceof ICompilationUnit) {
+ path= ((IJavaElement) element).getPath();
+ }
+ if (path != null) {
+ if (FileBuffers.getTextFileBufferManager().getFileBuffer(path, LocationKind.NORMALIZE) != null) {
+ decoration.setFont(fBold);
+ }
+ }
+ }
+
+ private void update(IPath location) {
+ IFile file= FileBuffers.getWorkspaceFileAtLocation(location);
+ if (file != null) {
+ boolean hasChanges= false;
+ synchronized (this) {
+ hasChanges= fChangedResources.add(file);
+ }
+ if (hasChanges) {
+ if (fNotifierJob == null) {
+ fNotifierJob= new UIJob(Display.getDefault(), "Update Java test decorations") {
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ runPendingUpdates();
+ return Status.OK_STATUS;
+ }
+ };
+ fNotifierJob.setSystem(true);
+ }
+ fNotifierJob.schedule();
+ }
+ }
+ }
+
+ private void runPendingUpdates() {
+ Object[] resourceToUpdate= null;
+ synchronized (this) {
+ resourceToUpdate= fChangedResources.toArray();
+ fChangedResources.clear();
+ }
+ if (resourceToUpdate.length > 0) {
+ LabelProviderChangedEvent event= new LabelProviderChangedEvent(this, resourceToUpdate);
+ fireLabelProviderChanged(event);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
+ */
+ public void dispose() {
+ fColor.dispose();
+ FileBuffers.getTextFileBufferManager().removeFileBufferListener(fListener);
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MultiElementListSelectorExample.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MultiElementListSelectorExample.java
new file mode 100644
index 000000000..ee862e427
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MultiElementListSelectorExample.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+
+import java.util.Random;
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.core.runtime.IStatus;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+
+import org.eclipse.jdt.internal.ui.dialogs.MultiElementListSelectionDialog;
+import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
+
+/*
+ * NOTE: Running this example will open the dialog but elements will appear
+ * because the dialog internally uses a FilteredTree which only works when the
+ * workbench is running.
+ */
+public class MultiElementListSelectorExample {
+
+
+ public static void main(String[] args) {
+
+
+ ISelectionStatusValidator validator= new ISelectionStatusValidator() {
+ public IStatus validate(Object[] selection) {
+ if (selection != null && selection.length == 1) {
+ return new StatusInfo();
+ } else {
+ StatusInfo status= new StatusInfo();
+ status.setError("Single selection");
+ return status;
+ }
+
+ }
+ };
+
+
+
+ Random random= new Random();
+
+ ILabelProvider elementRenderer= new org.eclipse.jface.viewers.LabelProvider() {
+ public String getText(Object element) {
+ return element.toString();
+ }
+ };
+
+ int nPages= 3;
+ Object[][] elements= new Object[nPages][];
+ for (int i= 0; i < nPages; i++) {
+ int size= random.nextInt(15);
+ elements[i]= new String[size];
+ for (int k= 0; k < size; k++) {
+ elements[i][k]= "elem-" + i + "-" + k;
+ }
+ }
+
+ Display display= new Display();
+ MultiElementListSelectionDialog d= new MultiElementListSelectionDialog(new Shell(display), elementRenderer);
+ d.setTitle("Title");
+ d.setIgnoreCase(true);
+ d.setMessage("this is a message");
+ d.setValidator(validator);
+ d.setElements(elements);
+
+ d.open();
+
+ Object[] res= d.getResult();
+ if (res != null) {
+ for (int i= 0; i < res.length; i++)
+ System.out.println(res[i]);
+ }
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyClasspathContainerInitializer.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyClasspathContainerInitializer.java
new file mode 100644
index 000000000..6ad1bdb55
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyClasspathContainerInitializer.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.jdt.core.ClasspathContainerInitializer;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+
+/**
+ *
+ */
+public class MyClasspathContainerInitializer extends ClasspathContainerInitializer {
+
+ public static class MyClasspathContainer implements IClasspathContainer {
+
+ private final IPath fPath;
+ private static final IPath MY_ARCHIVE= new Path("C:\\xy.jar");
+
+ public MyClasspathContainer(IPath path) {
+ fPath= path;
+ }
+
+ public IClasspathEntry[] getClasspathEntries() {
+ return new IClasspathEntry[] { JavaCore.newLibraryEntry(MY_ARCHIVE, null, null) };
+ }
+
+ public String getDescription() { return "My example"; }
+
+ public int getKind() { return IClasspathContainer.K_APPLICATION; }
+
+ public IPath getPath() { return fPath; }
+
+ }
+
+ public void initialize(IPath containerPath, IJavaProject project) throws CoreException {
+ IClasspathContainer[] containers= { new MyClasspathContainer(containerPath) };
+ JavaCore.setClasspathContainer(containerPath, new IJavaProject[] { project }, containers, null);
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyClasspathContainerPage.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyClasspathContainerPage.java
new file mode 100644
index 000000000..4653b2283
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyClasspathContainerPage.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.jface.wizard.WizardPage;
+
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaCore;
+
+import org.eclipse.jdt.ui.wizards.IClasspathContainerPage;
+
+public class MyClasspathContainerPage extends WizardPage implements IClasspathContainerPage {
+
+ private IClasspathEntry fEntry;
+
+ public MyClasspathContainerPage() {
+ super("MyClasspathContainerPage");
+ setTitle("My Example Container");
+ }
+
+ public void createControl(Composite parent) {
+ Label label= new Label(parent, SWT.NONE);
+ if (fEntry == null) {
+ label.setText("Nothing to configure. Press 'Finish' to add new entry");
+ } else {
+ label.setText("Nothing to configure.");
+ setPageComplete(false);
+ }
+ setControl(label);
+ }
+
+ public boolean finish() {
+ if (fEntry == null) { // new entry
+ fEntry= JavaCore.newContainerEntry(new Path("org.eclipse.jdt.EXAMPLE_CONTAINER"));
+ }
+ return true;
+ }
+
+ public IClasspathEntry getSelection() {
+ return fEntry;
+ }
+
+ public void setSelection(IClasspathEntry containerEntry) {
+ fEntry= containerEntry;
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyJavadocExportWizardPage.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyJavadocExportWizardPage.java
new file mode 100644
index 000000000..fd22a1bf7
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyJavadocExportWizardPage.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+import java.util.List;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.jdt.ui.wizards.JavadocExportWizardPage;
+
+import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
+
+/* Adds a page to the Javadoc export wizard
+
+ <extension
+ point="org.eclipse.jdt.ui.javadocExportWizardPage">
+ <javadocExportWizardPage
+ description="My Javadoc Export Wizard Page"
+ class="org.eclipse.jdt.ui.examples.MyJavadocExportWizardPage"
+ id="org.eclipse.jdt.EXAMPLE_JD_EXPORT_WP">
+ </javadocExportWizardPage>
+ </extension>
+
+*/
+public class MyJavadocExportWizardPage extends JavadocExportWizardPage {
+
+ private Text fText;
+ private Text fText2;
+ private Button fButton;
+ private Label fLabel;
+ private Label fLabel2;
+
+ public MyJavadocExportWizardPage() {
+ }
+
+ public Control createContents(Composite parent) {
+ ModifyListener modifyListener= new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ validateInputs();
+ }
+ };
+
+ Composite composite= new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ composite.setLayout(new GridLayout(2, false));
+
+ fButton= new Button(composite, SWT.CHECK);
+ fButton.setLayoutData(new GridData(SWT.LEAD, SWT.TOP, false, false, 2, 1));
+ fButton.setText("Use taglet");
+ fButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ validateInputs();
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ validateInputs();
+ }
+ });
+ fButton.setSelection(false);
+
+
+ fLabel= new Label(composite, SWT.NONE);
+ fLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
+ fLabel.setText("Tag:");
+ fLabel.setEnabled(false);
+
+ fText= new Text(composite, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
+ fText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ fText.setText("");
+ fText.addModifyListener(modifyListener);
+ fText.setEnabled(false);
+
+ fLabel2= new Label(composite, SWT.NONE);
+ fLabel2.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
+ fLabel2.setText("Description:");
+ fLabel2.setEnabled(false);
+
+ fText2= new Text(composite, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
+ fText2.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ fText2.setText("");
+ fText2.addModifyListener(modifyListener);
+ fText2.setEnabled(false);
+
+ return composite;
+ }
+
+ protected void validateInputs() {
+ boolean isEnabled= fButton.getSelection();
+
+ fLabel.setEnabled(isEnabled);
+ fText.setEnabled(isEnabled);
+ fLabel2.setEnabled(isEnabled);
+ fText2.setEnabled(isEnabled);
+
+ StatusInfo status= new StatusInfo();
+
+ if (isEnabled) {
+ String text= fText.getText().trim();
+ if (text.length() == 0) {
+ status.setError("Enter a tag");
+ }
+
+ String text2= fText2.getText().trim();
+ if (text2.length() == 0) {
+ status.setError("Enter a description");
+ }
+ }
+ setStatus(status);
+ }
+
+ public void updateArguments(List vmOptions, List toolOptions) {
+ if (fButton.getSelection()) {
+ String tag= fText.getText().trim();
+ String description= fText2.getText().trim();
+
+ toolOptions.add(0, "-tag");
+ toolOptions.add(1, tag + ":a:"+ description); // do not quote here, Javadoc wizard will quote if necessary
+ }
+ }
+
+ public void updateAntScript(Element javadocXMLElement) {
+ if (fButton.getSelection()) {
+ String tag= fText.getText().trim();
+ String description= fText2.getText().trim();
+
+ Document document= javadocXMLElement.getOwnerDocument();
+
+ Element tagElement= document.createElement("tag");
+ tagElement.setAttribute("name", tag);
+ tagElement.setAttribute("description", description);
+
+ javadocXMLElement.appendChild(tagElement);
+ }
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyProjectCreationWizard.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyProjectCreationWizard.java
new file mode 100644
index 000000000..90791862f
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyProjectCreationWizard.java
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
+
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+
+import org.eclipse.jdt.launching.JavaRuntime;
+
+import org.eclipse.jdt.ui.wizards.JavaCapabilityConfigurationPage;
+
+/**
+<extension
+ point="org.eclipse.ui.newWizards">
+ <wizard
+ id="org.eclipse.jdt.ui.examples.MyProjectCreationWizard"
+ name="My project"
+ class="org.eclipse.jdt.ui.examples.MyProjectCreationWizard"
+ category="org.eclipse.jdt.ui.java"
+ project="true"
+ finalPerspective="org.eclipse.jdt.ui.JavaPerspective"
+ icon="icons/full/ctool16/newjprj_wiz.gif">
+ <description>My project</description>
+ </wizard>
+</extension>
+ */
+
+/**
+ * This example shows how to implement an own project wizard that uses the
+ * JavaCapabilityConfigurationPage to allow the user to configure the Java build path.
+ */
+public class MyProjectCreationWizard extends Wizard implements IExecutableExtension, INewWizard {
+
+ private WizardNewProjectCreationPage fMainPage;
+ private JavaCapabilityConfigurationPage fJavaPage;
+
+ private IConfigurationElement fConfigElement;
+
+ private IWorkbench fWorkbench;
+ public MyProjectCreationWizard() {
+ setWindowTitle("New XY Project");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
+ */
+ public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {
+ // The config element will be used in <code>finishPage</code> to set the result perspective.
+ fConfigElement= cfig;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ fWorkbench= workbench;
+ }
+
+ /* (non-Javadoc)
+ * @see Wizard#addPages
+ */
+ public void addPages() {
+ super.addPages();
+ fMainPage= new WizardNewProjectCreationPage("NewProjectCreationWizard");
+ fMainPage.setTitle("New");
+ fMainPage.setDescription("Create a new XY project.");
+
+ // the main page
+ addPage(fMainPage);
+
+ // the Java build path configuration page
+ fJavaPage= new JavaCapabilityConfigurationPage() {
+ public void setVisible(boolean visible) {
+ // need to override to react to changes on first page
+ updatePage();
+ super.setVisible(visible);
+ }
+ };
+ addPage(fJavaPage);
+
+ // TODO: add your pages here
+ }
+
+ private void updatePage() {
+ IJavaProject jproject= JavaCore.create(fMainPage.getProjectHandle());
+ if (!jproject.equals(fJavaPage.getJavaProject())) {
+ IClasspathEntry[] buildPath= {
+ JavaCore.newSourceEntry(jproject.getPath().append("in")),
+ JavaRuntime.getDefaultJREContainerEntry()
+ };
+ IPath outputLocation= jproject.getPath().append("out");
+ fJavaPage.init(jproject, outputLocation, buildPath, false);
+ }
+ }
+
+ private void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
+ if (monitor == null) {
+ monitor= new NullProgressMonitor();
+ }
+ try {
+ monitor.beginTask("Creating XY project...", 3); // 3 steps
+
+ IProject project= fMainPage.getProjectHandle();
+ IPath locationPath= fMainPage.getLocationPath();
+
+ // create the project
+ IProjectDescription desc= project.getWorkspace().newProjectDescription(project.getName());
+ if (!fMainPage.useDefaults()) {
+ desc.setLocation(locationPath);
+ }
+ project.create(desc, new SubProgressMonitor(monitor, 1));
+ project.open(new SubProgressMonitor(monitor, 1));
+
+ updatePage();
+ fJavaPage.configureJavaProject(new SubProgressMonitor(monitor, 1));
+ // TODO: configure your page / nature
+
+ // change to the perspective specified in the plugin.xml
+ BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
+ BasicNewResourceWizard.selectAndReveal(project, fWorkbench.getActiveWorkbenchWindow());
+
+ } finally {
+ monitor.done();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see Wizard#performFinish
+ */
+ public boolean performFinish() {
+ WorkspaceModifyOperation op= new WorkspaceModifyOperation() {
+ protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
+ finishPage(monitor);
+ }
+ };
+ try {
+ getContainer().run(false, true, op);
+ } catch (InvocationTargetException e) {
+ return false; // TODO: should open error dialog and log
+ } catch (InterruptedException e) {
+ return false; // canceled
+ }
+ return true;
+ }
+
+
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyProjectCreationWizard2.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyProjectCreationWizard2.java
new file mode 100644
index 000000000..70042b7aa
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyProjectCreationWizard2.java
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
+
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+
+import org.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageOne;
+import org.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageTwo;
+
+/**
+<extension
+ point="org.eclipse.ui.newWizards">
+ <wizard
+ id="org.eclipse.jdt.ui.examples.MyProjectCreationWizard2"
+ name="My Project 2"
+ class="org.eclipse.jdt.ui.examples.MyProjectCreationWizard2"
+ category="org.eclipse.jdt.ui.java"
+ project="true"
+ finalPerspective="org.eclipse.jdt.ui.JavaPerspective"
+ icon="icons/full/ctool16/newjprj_wiz.gif">
+ <description>My project 2</description>
+ </wizard>
+</extension>
+ */
+
+/**
+ * This example shows how to implement an own project wizard that uses the
+ * JavaCapabilityConfigurationPage to allow the user to configure the Java build path.
+ */
+public class MyProjectCreationWizard2 extends Wizard implements IExecutableExtension, INewWizard {
+
+ private NewJavaProjectWizardPageOne fMainPage;
+ private NewJavaProjectWizardPageTwo fJavaPage;
+ private IWizardPage fExtraPage;
+
+ private IConfigurationElement fConfigElement;
+
+
+ public MyProjectCreationWizard2() {
+ setWindowTitle("New ZZ Project");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
+ */
+ public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {
+ // The config element will be used in <code>finishPage</code> to set the result perspective.
+ fConfigElement= cfig;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ }
+
+ /* (non-Javadoc)
+ * @see Wizard#addPages
+ */
+ public void addPages() {
+ super.addPages();
+
+ // simplified main page: no extrenal laoctaion, no src/bin selection always create our own layout
+ fMainPage= new NewJavaProjectWizardPageOne() {
+ public void createControl(Composite parent) {
+ initializeDialogUnits(parent);
+
+ Composite composite= new Composite(parent, SWT.NULL);
+ composite.setFont(parent.getFont());
+ composite.setLayout(new GridLayout(1, false));
+ composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ // create UI elements
+ Control nameControl= createNameControl(composite);
+ nameControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Control jreControl= createJRESelectionControl(composite);
+ jreControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Control workingSetControl= createWorkingSetControl(composite);
+ workingSetControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Control infoControl= createInfoControl(composite);
+ infoControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ setControl(composite);
+ }
+
+ public IClasspathEntry[] getSourceClasspathEntries() {
+ IPath path1= new Path(getProjectName()).append("src").makeAbsolute();
+ IPath path2= new Path(getProjectName()).append("tests").makeAbsolute();
+ return new IClasspathEntry[] { JavaCore.newSourceEntry(path1), JavaCore.newSourceEntry(path2) };
+ }
+
+ public IPath getOutputLocation() {
+ IPath path1= new Path(getProjectName()).append("classes").makeAbsolute();
+ return path1;
+ }
+ };
+ fMainPage.setProjectName("ZZ");
+
+ // the main page
+ addPage(fMainPage);
+
+ // the Java build path configuration page
+ fJavaPage= new NewJavaProjectWizardPageTwo(fMainPage);
+
+ addPage(fJavaPage);
+
+ fExtraPage= new WizardPage("My Page") {
+
+ public void createControl(Composite parent) {
+ initializeDialogUnits(parent);
+
+ Button button= new Button(parent, SWT.CHECK);
+ button.setText("Make it a special project");
+
+ setControl(button);
+ }
+
+ };
+
+
+ addPage(fExtraPage);
+ }
+
+
+ /* (non-Javadoc)
+ * @see Wizard#performFinish
+ */
+ public boolean performFinish() {
+ WorkspaceModifyOperation op= new WorkspaceModifyOperation() {
+ protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
+ fJavaPage.performFinish(monitor);
+ // use the result from the extra page
+ }
+ };
+ try {
+ getContainer().run(false, true, op);
+
+ IJavaProject newElement= fJavaPage.getJavaProject();
+
+ IWorkingSet[] workingSets= fMainPage.getWorkingSets();
+ if (workingSets.length > 0) {
+ PlatformUI.getWorkbench().getWorkingSetManager().addToWorkingSets(newElement, workingSets);
+ }
+ BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
+ BasicNewResourceWizard.selectAndReveal(newElement.getResource(), PlatformUI.getWorkbench().getActiveWorkbenchWindow());
+
+
+ } catch (InvocationTargetException e) {
+ return false; // TODO: should open error dialog and log
+ } catch (InterruptedException e) {
+ return false; // canceled
+ }
+ return true;
+ }
+
+ public boolean performCancel() {
+ fJavaPage.performCancel();
+ return true;
+ }
+
+
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyQuickAssistProcessor.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyQuickAssistProcessor.java
new file mode 100644
index 000000000..cd7ae9a47
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyQuickAssistProcessor.java
@@ -0,0 +1,227 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.core.filebuffers.LocationKind;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+
+import org.eclipse.ui.IEditorPart;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.StringLiteral;
+import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
+
+import org.eclipse.jdt.ui.tests.quickfix.QuickFixTest;
+import org.eclipse.jdt.ui.text.java.IInvocationContext;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.jdt.ui.text.java.IProblemLocation;
+import org.eclipse.jdt.ui.text.java.IQuickAssistProcessor;
+
+import org.eclipse.jdt.internal.ui.JavaPluginImages;
+import org.eclipse.jdt.internal.ui.text.correction.proposals.ASTRewriteCorrectionProposal;
+import org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeCorrectionProposal;
+
+/**
+ *
+ */
+public class MyQuickAssistProcessor implements IQuickAssistProcessor {
+
+ private boolean getConvertProposal(IInvocationContext context, List result) {
+ ASTNode node= context.getCoveringNode();
+ if (!(node instanceof StringLiteral)) {
+ return false;
+ }
+ if (result == null) {
+ return true;
+ }
+
+ StringLiteral oldLiteral= (StringLiteral) node;
+
+ AST ast= node.getAST();
+ StringLiteral newLiteral= ast.newStringLiteral();
+ newLiteral.setEscapedValue(toUpperCase(oldLiteral.getEscapedValue()));
+
+ ASTRewrite rewrite= ASTRewrite.create(ast);
+ rewrite.replace(oldLiteral, newLiteral, null);
+ Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
+ result.add(new ASTRewriteCorrectionProposal("To uppercase", context.getCompilationUnit(), rewrite, 10, image));
+ return true;
+ }
+
+ private String toUpperCase(String escapedValue) {
+ int length= escapedValue.length();
+ StringBuffer buf= new StringBuffer(length);
+ boolean inEscape= false;
+ for (int i= 0; i < length; i++) {
+ char ch= escapedValue.charAt(i);
+ if (inEscape) {
+ buf.append(ch);
+ inEscape= false;
+ } else if (ch == '\\') {
+ buf.append(ch);
+ inEscape= true;
+ } else {
+ buf.append(Character.toUpperCase(ch));
+ }
+ }
+ return buf.toString();
+ }
+
+ private boolean getStringWrappedProposal(final IInvocationContext context, List result) throws CoreException {
+ int selectionOffset= context.getSelectionOffset();
+ int selectionLength= context.getSelectionLength();
+
+ ITextFileBufferManager textFileBufferManager= FileBuffers.getTextFileBufferManager();
+ IPath path= context.getCompilationUnit().getPath();
+
+ try {
+ textFileBufferManager.connect(path, LocationKind.NORMALIZE, null);
+ IDocument document= textFileBufferManager.getTextFileBuffer(path, LocationKind.NORMALIZE).getDocument();
+ int startLine= document.getLineOfOffset(selectionOffset);
+ int endLine= document.getLineOfOffset(selectionOffset + selectionLength);
+
+
+ if (startLine == endLine) {
+ return false;
+ }
+ if (result == null) {
+ return true;
+ }
+ Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
+ result.add(new ChangeCorrectionProposal("Wrap in buf.append() (to clipboard)", null, 3, image) {
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal#performChange(org.eclipse.ui.IEditorPart, org.eclipse.jface.text.IDocument)
+ */
+ protected void performChange(IEditorPart activeEditor, IDocument doc) throws CoreException {
+ wrapAndCopyToClipboard(context, doc);
+ super.performChange(activeEditor, doc);
+ }
+ });
+ } catch (BadLocationException e) {
+ return false;
+ } finally {
+ textFileBufferManager.disconnect(path, LocationKind.NORMALIZE, null);
+ }
+ return true;
+ }
+
+ private boolean getCreateQuickFixTestProposal(final IInvocationContext context, List result) throws CoreException {
+ final ICompilationUnit cu= context.getCompilationUnit();
+ if (context.getSelectionOffset() != 0 || context.getSelectionLength() != cu.getSourceRange().getLength()) {
+ return false;
+ }
+ if (context.getASTRoot().getProblems().length != 1) {
+ return false;
+ }
+
+ if (result == null) {
+ return true;
+ }
+
+ Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
+ result.add(new ChangeCorrectionProposal("Create quick fix test", null, 3, image) {
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal#performChange(org.eclipse.ui.IEditorPart, org.eclipse.jface.text.IDocument)
+ */
+ protected void performChange(IEditorPart activeEditor, IDocument doc) throws CoreException {
+ try {
+ String content= QuickFixTest.getPreviewsInBufAppend(cu);
+ if (content != null) {
+ Clipboard clipboard= new Clipboard(Display.getCurrent());
+ clipboard.setContents(new Object[] { content }, new Transfer[] { TextTransfer.getInstance() } );
+ super.performChange(activeEditor, doc);
+ return;
+ }
+ } catch (BadLocationException e) {
+ // ignore
+ }
+ MessageDialog.openError(activeEditor.getSite().getShell(), "Create quick fix test", "Could not create quick fix test");
+
+ }
+ });
+ return true;
+ }
+
+ protected void wrapAndCopyToClipboard(IInvocationContext context, IDocument document) {
+ StringBuffer buf= new StringBuffer();
+ try {
+ int selectionOffset= context.getSelectionOffset();
+ int selectionLength= context.getSelectionLength();
+ int startLine= document.getLineOfOffset(selectionOffset);
+ int endLine= document.getLineOfOffset(selectionOffset + selectionLength);
+
+ for (int i= startLine; i <= endLine; i++) {
+ IRegion lineInfo= document.getLineInformation(i);
+ String lineContent= document.get(lineInfo.getOffset(), lineInfo.getLength());
+ buf.append("buf.append(\"");
+ for (int k= 0; k < lineContent.length(); k++) {
+ char ch= lineContent.charAt(k);
+ if (ch == '\t') {
+ buf.append(" "); // 4 spaces
+ } else if (ch == '"' || ch == '\\') {
+ buf.append('\\').append(ch);
+ } else {
+ buf.append(ch);
+ }
+ }
+ buf.append("\\n\");");
+ if (i != endLine) {
+ buf.append('\n');
+ }
+ }
+ } catch (BadLocationException e) {
+ // ignore
+ }
+ Clipboard clipboard= new Clipboard(Display.getCurrent());
+ clipboard.setContents(new Object[] { buf.toString() }, new Transfer[] { TextTransfer.getInstance() } );
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.ui.text.java.IQuickAssistProcessor#hasAssists(org.eclipse.jdt.ui.text.java.IInvocationContext)
+ */
+ public boolean hasAssists(IInvocationContext context) throws CoreException {
+ return getConvertProposal(context, null) || getStringWrappedProposal(context, null) || getCreateQuickFixTestProposal(context, null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.ui.text.java.IQuickAssistProcessor#getAssists(org.eclipse.jdt.ui.text.java.IInvocationContext, org.eclipse.jdt.ui.text.java.IProblemLocation[])
+ */
+ public IJavaCompletionProposal[] getAssists(IInvocationContext context, IProblemLocation[] locations) throws CoreException {
+ ArrayList resultingCollections= new ArrayList();
+ getConvertProposal(context, resultingCollections);
+ getStringWrappedProposal(context, resultingCollections);
+ getCreateQuickFixTestProposal(context, resultingCollections);
+ return (IJavaCompletionProposal[]) resultingCollections.toArray(new IJavaCompletionProposal[resultingCollections.size()]);
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyQuickFixProcessor.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyQuickFixProcessor.java
new file mode 100644
index 000000000..0e51257bd
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyQuickFixProcessor.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.compiler.IProblem;
+
+import org.eclipse.jdt.ui.text.java.IInvocationContext;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.jdt.ui.text.java.IProblemLocation;
+import org.eclipse.jdt.ui.text.java.IQuickFixProcessor;
+
+import org.eclipse.jdt.internal.ui.text.correction.proposals.ReplaceCorrectionProposal;
+
+/**
+ *
+ */
+public class MyQuickFixProcessor implements IQuickFixProcessor {
+/* Active on files with the name A.java
+
+<extension
+ point="org.eclipse.jdt.ui.quickFixProcessors">
+ <quickFixProcessor
+ id= "org.eclipse.jdt.ui.examples.MyQuickFixProcessor"
+ class="org.eclipse.jdt.ui.examples.MyQuickFixProcessor"
+ name="Example Quick Fix Processor">
+ <objectState adaptable="org.eclipse.core.resources.IResource">
+ <property name="name" value="A.java"/>
+ </objectState>
+ </quickFixProcessor>
+</extension>
+
+*/
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.text.correction.ICorrectionProcessor#hasCorrections(org.eclipse.jdt.core.ICompilationUnit, int)
+ */
+ public boolean hasCorrections(ICompilationUnit unit, int problemId) {
+ return (problemId == IProblem.NumericValueOutOfRange);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.text.correction.ICorrectionProcessor#getCorrections(org.eclipse.jdt.internal.ui.text.correction.IAssistContext, org.eclipse.jdt.internal.ui.text.correction.IProblemLocation[])
+ */
+ public IJavaCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations) throws CoreException {
+ for (int i= 0; i < locations.length; i++) {
+ if (locations[i].getProblemId() == IProblem.NumericValueOutOfRange) {
+ return getNumericValueOutOfRangeCorrection(context, locations[i]);
+ }
+ }
+ return null;
+ }
+
+ private IJavaCompletionProposal[] getNumericValueOutOfRangeCorrection(IInvocationContext context, IProblemLocation location) {
+ ICompilationUnit cu= context.getCompilationUnit();
+
+ ReplaceCorrectionProposal proposal= new ReplaceCorrectionProposal("Change to 0", cu, location.getOffset(), location.getLength(), "0", 5);
+ return new IJavaCompletionProposal[] { proposal };
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyRenameTypeParticipant.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyRenameTypeParticipant.java
new file mode 100644
index 000000000..885b3bbe5
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyRenameTypeParticipant.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEditGroup;
+
+import org.eclipse.search.core.text.TextSearchEngine;
+import org.eclipse.search.core.text.TextSearchMatchAccess;
+import org.eclipse.search.core.text.TextSearchRequestor;
+import org.eclipse.search.ui.text.FileTextSearchScope;
+
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.TextChange;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
+
+import org.eclipse.jdt.core.IType;
+
+
+/*
+ A rename participant that updates type references in '*.special' files.
+
+
+ <extension point="org.eclipse.ltk.core.refactoring.renameParticipants">
+ <renameParticipant
+ id="org.eclipse.jdt.ui.examples.MyRenameTypeParticipant"
+ name="Rename participant for *.special files"
+ class="org.eclipse.jdt.ui.examples.MyRenameTypeParticipant">
+ <enablement>
+ <with variable="affectedNatures">
+ <iterate operator="or">
+ <equals value="org.eclipse.jdt.core.javanature"/>
+ </iterate>
+ </with>
+ <with variable="element">
+ <instanceof value="org.eclipse.jdt.core.IType"/>
+ </with>
+ </enablement>
+ </renameParticipant>
+ </extension>
+
+ */
+
+
+public class MyRenameTypeParticipant extends RenameParticipant {
+
+ private IType fType;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object)
+ */
+ protected boolean initialize(Object element) {
+ fType= (IType) element;
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName()
+ */
+ public String getName() {
+ return "My special file participant"; //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
+ */
+ public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) {
+ return new RefactoringStatus();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public Change createChange(IProgressMonitor pm) throws CoreException {
+
+ final HashMap changes= new HashMap();
+ final String newName= getArguments().getNewName();
+
+ // use the text search engine to find matches in my special files
+ // in a real world implementation, clients would use their own, more precise search engine
+
+ IResource[] roots= { fType.getJavaProject().getProject() }; // limit to the current project
+ String[] fileNamePatterns= { "*.special" }; //$NON-NLS-1$ // all files with file suffix 'special'
+ FileTextSearchScope scope= FileTextSearchScope.newSearchScope(roots , fileNamePatterns, false);
+ Pattern pattern= Pattern.compile(fType.getElementName()); // only find the simple name of the type
+
+ TextSearchRequestor collector= new TextSearchRequestor() {
+ public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess) throws CoreException {
+ IFile file= matchAccess.getFile();
+ TextFileChange change= (TextFileChange) changes.get(file);
+ if (change == null) {
+ TextChange textChange= getTextChange(file); // an other participant already modified that file?
+ if (textChange != null) {
+ return false; // don't try to merge changes
+ }
+ change= new TextFileChange(file.getName(), file);
+ change.setEdit(new MultiTextEdit());
+ changes.put(file, change);
+ }
+ ReplaceEdit edit= new ReplaceEdit(matchAccess.getMatchOffset(), matchAccess.getMatchLength(), newName);
+ change.addEdit(edit);
+ change.addTextEditGroup(new TextEditGroup("Update type reference", edit)); //$NON-NLS-1$
+ return true;
+ }
+ };
+ TextSearchEngine.create().search(scope, collector, pattern, pm);
+
+ if (changes.isEmpty())
+ return null;
+
+ CompositeChange result= new CompositeChange("My special file updates"); //$NON-NLS-1$
+ for (Iterator iter= changes.values().iterator(); iter.hasNext();) {
+ result.add((Change) iter.next());
+ }
+ return result;
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TabExample.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TabExample.java
new file mode 100644
index 000000000..dcff6c13f
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TabExample.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+
+import org.eclipse.jface.viewers.LabelProvider;
+
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField;
+
+
+public class TabExample {
+ private Shell fShell;
+
+ public TabExample() {
+ }
+
+ public TabExample close () {
+ if ((fShell != null) && (!fShell.isDisposed ())) fShell.dispose ();
+ fShell= null;
+ return this;
+ }
+
+ public TabExample open () {
+ fShell= new Shell ();
+ fShell.setText("TabTest");
+ fShell.setLayout(new GridLayout());
+
+ TabFolder folder= new TabFolder(fShell, SWT.NONE);
+ folder.setLayoutData(new GridData(GridData.FILL_BOTH));
+ //folder.setLayout(new PageContainerFillLayout(0, 0, 20, 20));
+ //folder.setLayout(new FillLayout());
+
+ /*folder.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ turnToPage(event);
+ }
+ });*/
+
+ TabItem item;
+ Label label;
+
+ item= new TabItem(folder, SWT.NONE);
+ item.setText("Tab0");
+
+ String[] addButtons= new String[] {
+ /* 0 */ "Add1",
+ /* 1 */ "Add2",
+ /* 2 */ null,
+ /* 3 */ "Remove"
+ };
+ ListDialogField list= new ListDialogField(new Adapter(), addButtons, new LabelProvider());
+ list.setRemoveButtonIndex(3);
+ list.setLabelText("List: ");
+
+
+ Composite c1= new Composite(folder, SWT.NONE);
+ LayoutUtil.doDefaultLayout(c1, new DialogField[] { list }, true);
+
+ item.setControl(c1);
+
+ item= new TabItem(folder, SWT.NONE);
+ item.setText("Tab1");
+ label= new Label(folder, SWT.LEFT);
+ label.setText("Tab1");
+ item.setControl(label);
+
+ item= new TabItem(folder, SWT.NONE);
+ item.setText("Tab2");
+ label= new Label(folder, SWT.LEFT);
+ label.setText("Tab2");
+ item.setControl(label);
+
+ item= new TabItem(folder, SWT.NONE);
+ item.setText("Tab3");
+ label= new Label(folder, SWT.LEFT);
+ label.setText("Tab3");
+ item.setControl(label);
+
+ fShell.setSize(400,500);
+ fShell.open ();
+ return this;
+ }
+
+
+ private class Adapter implements IStringButtonAdapter, IDialogFieldListener, IListAdapter {
+
+ // -------- IStringButtonAdapter
+ public void changeControlPressed(DialogField field) {
+ }
+
+ // -------- IListAdapter
+ public void customButtonPressed(ListDialogField field, int index) {
+ }
+
+ public void selectionChanged(ListDialogField field) {
+ }
+
+ // -------- IDialogFieldListener
+ public void dialogFieldChanged(DialogField field) {
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#doubleClicked(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField)
+ */
+ public void doubleClicked(ListDialogField field) {
+ }
+ }
+
+ public TabExample run () {
+ Display display= fShell.getDisplay ();
+ while (!fShell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ return this;
+ }
+
+ public static void main(java.lang.String[] args) {
+ new TabExample().open().run().close();
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TestMoveDescriptorAction.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TestMoveDescriptorAction.java
new file mode 100644
index 000000000..2d8b2c8f2
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TestMoveDescriptorAction.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.jdt.testplugin.JavaTestPlugin;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.ltk.core.refactoring.CheckConditionsOperation;
+import org.eclipse.ltk.core.refactoring.PerformRefactoringOperation;
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.core.refactoring.RefactoringContribution;
+import org.eclipse.ltk.core.refactoring.RefactoringCore;
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.refactoring.IJavaRefactorings;
+import org.eclipse.jdt.core.refactoring.descriptors.MoveDescriptor;
+
+/** In plugin.xml:
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ objectClass="org.eclipse.jdt.core.ICompilationUnit"
+ id="org.eclipse.jdt.ui.examples.TestMoveDescriptorAction">
+ <action
+ label="Move to default package (jdt.ui.tests)"
+ tooltip="Move to default package"
+ class="org.eclipse.jdt.ui.examples.TestMoveDescriptorAction"
+ menubarPath="TestMoveDescriptorAction"
+ enablesFor="1"
+ id="TestMoveDescriptorAction">
+ </action>
+ </objectContribution>
+ </extension>
+*/
+
+public class TestMoveDescriptorAction extends Action implements IActionDelegate {
+
+ private ICompilationUnit fCU;
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ try {
+ if (fCU != null) {
+ PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ performAction(monitor);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ });
+ }
+ } catch (Exception e) {
+ JavaTestPlugin.log(e);
+ }
+
+ }
+ private void performAction(IProgressMonitor monitor) throws CoreException {
+
+ IPackageFragmentRoot root= (IPackageFragmentRoot) fCU.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
+
+ RefactoringContribution refactoringContribution= RefactoringCore.getRefactoringContribution(IJavaRefactorings.MOVE);
+ RefactoringDescriptor desc= refactoringContribution.createDescriptor();
+ MoveDescriptor moveDes= (MoveDescriptor) desc;
+ moveDes.setComment("Moving cu");
+ moveDes.setDescription("Moving cu");
+ moveDes.setDestination(root.getPackageFragment(""));
+ moveDes.setProject(root.getJavaProject().getElementName());
+ moveDes.setMoveResources(new IFile[0], new IFolder[0], new ICompilationUnit[] { fCU });
+ moveDes.setUpdateReferences(true);
+
+ RefactoringStatus status= new RefactoringStatus();
+
+ Refactoring refactoring= moveDes.createRefactoring(status);
+ PerformRefactoringOperation op= new PerformRefactoringOperation(refactoring, CheckConditionsOperation.ALL_CONDITIONS);
+
+ op.run(monitor);
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ fCU= null;
+ if (selection instanceof IStructuredSelection) {
+ Object object= ((IStructuredSelection) selection).getFirstElement();
+ if (object instanceof ICompilationUnit) {
+ fCU= (ICompilationUnit) object;
+
+ }
+ }
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TreeListDialogFieldExample.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TreeListDialogFieldExample.java
new file mode 100644
index 000000000..1fa27625f
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TreeListDialogFieldExample.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+
+import java.util.Random;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.jface.viewers.LabelProvider;
+
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.TreeListDialogField;
+
+
+public class TreeListDialogFieldExample {
+ private Shell fShell;
+
+ public TreeListDialogFieldExample() {
+ }
+
+ public TreeListDialogFieldExample close () {
+ if ((fShell != null) && (!fShell.isDisposed ())) fShell.dispose ();
+ fShell= null;
+ return this;
+ }
+
+
+
+ public TreeListDialogFieldExample open () {
+ fShell= new Shell ();
+ fShell.setText("Message Dialog Example");
+ fShell.setLayout(new GridLayout());
+
+ Adapter adapter= new Adapter();
+
+
+ String[] addButtons= new String[] {
+ /* 0 */ "Add1",
+ /* 1 */ "Add2",
+ /* 2 */ null,
+ /* 3 */ "Up",
+ /* 4 */ "Down",
+ /* 5 */ null,
+ /* 6 */ "Remove"
+ };
+
+ TreeListDialogField list= new TreeListDialogField(adapter, addButtons, new LabelProvider());
+ list.setUpButtonIndex(3);
+ list.setDownButtonIndex(4);
+ list.setRemoveButtonIndex(6);
+ list.setLabelText("List: ");
+
+
+ for (int i= 0; i < 30; i++) {
+ list.addElement(i + "firstxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
+ }
+
+
+ LayoutUtil.doDefaultLayout(fShell, new DialogField[] { list }, false);
+
+ fShell.setSize(fShell.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ fShell.open ();
+ return this;
+ }
+
+ private static Random fgRandom= new Random();
+
+ private class Adapter implements ITreeListAdapter {
+
+ // -------- ITreeListAdapter
+ public void customButtonPressed(TreeListDialogField field, int index) {
+ field.addElement("elementxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-" + fgRandom.nextInt());
+ }
+
+ public void selectionChanged(TreeListDialogField field) {}
+
+ public Object[] getChildren(TreeListDialogField field, Object element) {
+ if (field.getElements().contains(element)) {
+ return new String[] {
+ "Source Attachment: c:/hello/z.zip",
+ "Javadoc Location: http://www.oo.com/doc"
+ };
+ }
+ return new String[0];
+ }
+
+ public Object getParent(TreeListDialogField field, Object element) {
+ return null;
+ }
+
+ public boolean hasChildren(TreeListDialogField field, Object element) {
+ return field.getElements().contains(element);
+ }
+
+ public void doubleClicked(TreeListDialogField field) {
+ }
+
+ public void keyPressed(TreeListDialogField field, KeyEvent event) {
+ }
+
+ }
+
+ public TreeListDialogFieldExample run () {
+ Display display= fShell.getDisplay ();
+ while (!fShell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ return this;
+ }
+
+ public static void main(java.lang.String[] args) {
+ new TreeListDialogFieldExample().open().run().close();
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TwoPaneElementSelectorExample.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TwoPaneElementSelectorExample.java
new file mode 100644
index 000000000..5c784140b
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TwoPaneElementSelectorExample.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples;
+
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+
+import org.eclipse.ui.dialogs.TwoPaneElementSelector;
+
+
+
+
+public class TwoPaneElementSelectorExample {
+
+
+ public static void main(String[] args) {
+ java.util.Random random= new java.util.Random();
+ Object[] elements= new Object[8000];
+ for (int i= 0; i < elements.length; i++)
+ elements[i]= new Integer(random.nextInt()).toString();
+ ILabelProvider elementRenderer= new org.eclipse.jface.viewers.LabelProvider() {
+ public String getText(Object element) {
+ return element.toString();
+ }
+ };
+ ILabelProvider qualfierRenderer= new org.eclipse.jface.viewers.LabelProvider() {
+ public String getText(Object element) {
+ return element.toString();
+ }
+ };
+ Display display= new Display();
+ TwoPaneElementSelector d= new TwoPaneElementSelector(new Shell(display), elementRenderer, qualfierRenderer);
+ d.setTitle("Title");
+ d.setMessage("this is a message");
+ d.setElements(elements);
+
+ d.open();
+
+ Object res= d.getResult();
+ System.out.println("res= "+res);
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/filters/AFileFilter.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/filters/AFileFilter.java
new file mode 100644
index 000000000..207366b68
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/filters/AFileFilter.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples.filters;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+
+public class AFileFilter extends ViewerFilter {
+
+ public AFileFilter() {
+ // TODO Auto-generated constructor stub
+ }
+
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (element instanceof ICompilationUnit) {
+ return !((ICompilationUnit) element).getElementName().equals("A.java");
+ }
+ return true;
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/filters/PureProjectFilter.java b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/filters/PureProjectFilter.java
new file mode 100644
index 000000000..fc8bf870f
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/filters/PureProjectFilter.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.examples.filters;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.core.resources.IProject;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+import org.eclipse.jdt.core.IJavaProject;
+
+public class PureProjectFilter extends ViewerFilter {
+
+ public PureProjectFilter() {
+ // TODO Auto-generated constructor stub
+ }
+
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (element instanceof IJavaProject) {
+ element= ((IJavaProject) element).getResource();
+ }
+ if (element instanceof IProject) {
+ IProject proj= (IProject) element;
+ if (!proj.isOpen())
+ return false;
+ try {
+ String[] natureIds= proj.getDescription().getNatureIds();
+ return natureIds.length == 1;
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/icons/red_dot.gif b/testplugins/org.eclipse.jdt.ui.tests/icons/red_dot.gif
new file mode 100644
index 000000000..8983df6f6
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/icons/red_dot.gif
Binary files differ
diff --git a/testplugins/org.eclipse.jdt.ui.tests/ipl-v10.html b/testplugins/org.eclipse.jdt.ui.tests/ipl-v10.html
new file mode 100644
index 000000000..c865637b6
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/ipl-v10.html
@@ -0,0 +1,252 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<!-- saved from url=(0040)http://www.openafs.org/dl/license10.html -->
+<HTML><HEAD><TITLE>IBM Public License Version 1.0</TITLE>
+<META content="IBM Public License Version 1.0" name=ABSTRACT>
+<META content="IBM Public License Version 1.0" name=DESCRIPTION>
+<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
+<META content="MSHTML 6.00.2800.1491" name=GENERATOR></HEAD>
+<BODY text=#000000 bgColor=#ffffff leftMargin=2 topMargin=2 marginheight="2"
+marginwidth="2">
+<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
+ <TBODY>
+ <TR>
+ <TD width=5 rowSpan=2><SPACER width="5" type="block"></TD>
+ <TD vAlign=top><BR><FONT face="HELVETICA, HELV, ARIAL" size=+1>IBM Public
+ License Version 1.0</FONT> <FONT face="HELVETICA, HELV, ARIAL" size=-1>
+ <P><FONT size=2>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF
+ THIS IBM PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
+ DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS
+ AGREEMENT.</FONT>
+ <P><FONT size=2></FONT>
+ <P><FONT size=2><B>1. DEFINITIONS</B></FONT>
+ <P><FONT size=2>"Contribution" means: </FONT>
+ <UL><FONT size=2>a) in the case of International Business Machines
+ Corporation ("IBM"), the Original Program, and </FONT></UL>
+ <UL><FONT size=2>b) in the case of each Contributor, </FONT></UL>
+ <UL><FONT size=2>i) changes to the Program, and</FONT></UL>
+ <UL><FONT size=2>ii) additions to the Program;</FONT></UL>
+ <UL><FONT size=2>where such changes and/or additions to the Program
+ originate from and are distributed by that particular Contributor.
+ </FONT><FONT size=2>A Contribution 'originates' from a Contributor if it
+ was added to the Program by such Contributor itself or anyone acting on
+ such Contributor's behalf. </FONT><FONT size=2>Contributions do not
+ include additions to the Program which: (i) are separate modules of
+ software distributed in conjunction with the Program under their own
+ license agreement, and (ii) are not derivative works of the
+ Program.</FONT></UL>
+ <P><FONT size=2></FONT>
+ <P><FONT size=2>"Contributor" means IBM and any other entity that
+ distributes the Program.</FONT>
+ <P><FONT size=2></FONT><FONT size=2></FONT>
+ <P><FONT size=2>"Licensed Patents " mean patent claims licensable by a
+ Contributor which are necessarily infringed by the use or sale of its
+ Contribution alone or when combined with the Program. </FONT>
+ <P><FONT size=2></FONT><FONT size=2></FONT>
+ <P><FONT size=2>"Original Program" means the original version of the
+ software accompanying this Agreement as released by IBM, including source
+ code, object code and documentation, if any.</FONT>
+ <P><FONT size=2></FONT>
+ <P><FONT size=2></FONT><FONT size=2>"Program" means the Original Program
+ and Contributions.</FONT>
+ <P><FONT size=2></FONT>
+ <P><FONT size=2>"Recipient" means anyone who receives the Program under
+ this Agreement, including all Contributors.</FONT>
+ <P><FONT size=2><B></B></FONT>
+ <P><FONT size=2><B>2. GRANT OF RIGHTS</B></FONT>
+ <UL><FONT size=2></FONT><FONT size=2>a) </FONT><FONT size=2>Subject to
+ the terms of this Agreement, each Contributor hereby grants</FONT><FONT
+ size=2> Recipient a non-exclusive, worldwide, royalty-free copyright
+ license to<FONT color=#ff0000> </FONT></FONT><FONT size=2>reproduce,
+ prepare derivative works of, publicly display, publicly perform,
+ distribute and sublicense the Contribution of such Contributor, if any,
+ and such derivative works, in source code and object code
+form.</FONT></UL>
+ <UL><FONT size=2></FONT></UL>
+ <UL><FONT size=2></FONT><FONT size=2>b) Subject to the terms of this
+ Agreement, each Contributor hereby grants </FONT><FONT size=2>Recipient
+ a non-exclusive, worldwide,<FONT color=#008000> </FONT></FONT><FONT
+ size=2>royalty-free patent license under Licensed Patents to make, use,
+ sell, offer to sell, import and otherwise transfer the Contribution of
+ such Contributor, if any, in source code and object code form. This
+ patent license shall apply to the combination of the Contribution and
+ the Program if, at the time the Contribution is added by the
+ Contributor, such addition of the Contribution causes such combination
+ to be covered by the Licensed Patents. The patent license shall not
+ apply to any other combinations which include the Contribution. No
+ hardware per se is licensed hereunder. </FONT></UL>
+ <UL><FONT size=2></FONT></UL>
+ <UL><FONT size=2>c) Recipient understands that although each Contributor
+ grants the licenses to its Contributions set forth herein, no assurances
+ are provided by any Contributor that the Program does not infringe the
+ patent or other intellectual property rights of any other entity. Each
+ Contributor disclaims any liability to Recipient for claims brought by
+ any other entity based on infringement of intellectual property rights
+ or otherwise. As a condition to exercising the rights and licenses
+ granted hereunder, each Recipient hereby assumes sole responsibility to
+ secure any other intellectual property rights needed, if any. For
+ example, if a third party patent license is required to allow Recipient
+ to distribute the Program, it is Recipient's responsibility to acquire
+ that license before distributing the Program.</FONT></UL>
+ <UL><FONT size=2></FONT></UL>
+ <UL><FONT size=2>d) Each Contributor represents that to its knowledge it
+ has sufficient copyright rights in its Contribution, if any, to grant
+ the copyright license set forth in this Agreement. </FONT></UL>
+ <UL><FONT size=2></FONT></UL>
+ <P><FONT size=2><B>3. REQUIREMENTS</B></FONT>
+ <P><FONT size=2><B></B>A Contributor may choose to distribute the Program
+ in object code form under its own license agreement, provided that:</FONT>
+
+ <UL><FONT size=2>a) it complies with the terms and conditions of this
+ Agreement; and</FONT></UL>
+ <UL><FONT size=2>b) its license agreement:</FONT></UL>
+ <UL><FONT size=2>i) effectively disclaims on behalf of all Contributors
+ all warranties and conditions, express and implied, including warranties
+ or conditions of title and non-infringement, and implied warranties or
+ conditions of merchantability and fitness for a particular purpose;
+ </FONT></UL>
+ <UL><FONT size=2>ii) effectively excludes on behalf of all Contributors
+ all liability for damages, including direct, indirect, special,
+ incidental and consequential damages, such as lost profits; </FONT></UL>
+ <UL><FONT size=2>iii) states that any provisions which differ from this
+ Agreement are offered by that Contributor alone and not by any other
+ party; and</FONT></UL>
+ <UL><FONT size=2>iv) states that source code for the Program is
+ available from such Contributor, and informs licensees how to obtain it
+ in a reasonable manner on or through a medium customarily used for
+ software exchange.<FONT color=#0000ff> </FONT><FONT
+ color=#ff0000></FONT></FONT></UL>
+ <UL><FONT size=2><FONT color=#ff0000></FONT></FONT><FONT
+ size=2></FONT></UL>
+ <P><FONT size=2>When the Program is made available in source code
+ form:</FONT>
+ <UL><FONT size=2>a) it must be made available under this Agreement; and
+ </FONT></UL>
+ <UL><FONT size=2>b) a copy of this Agreement must be included with each
+ copy of the Program. </FONT></UL>
+ <P><FONT size=2><FONT color=#0000ff></FONT></FONT>
+ <P><FONT size=2><FONT color=#0000ff></FONT></FONT><FONT size=2>Each
+ Contributor must include the following in a conspicuous location in the
+ Program: </FONT>
+ <P><FONT size=2></FONT>
+ <UL><FONT size=2>Copyright <FONT color=#ff0000> </FONT><FONT
+ color=green>{date here}</FONT></FONT><FONT size=2>, International
+ Business Machines Corporation and others. All Rights Reserved.
+</FONT></UL>
+ <P><FONT size=2></FONT>
+ <P><FONT size=2>In addition, each Contributor must identify itself as the
+ originator of its Contribution, if any, in a manner that reasonably allows
+ subsequent Recipients to identify the originator of the Contribution.
+ </FONT>
+ <P><FONT size=2></FONT>
+ <P><FONT size=2><B>4. COMMERCIAL DISTRIBUTION</B></FONT>
+ <P><FONT size=2>Commercial distributors of software may accept certain
+ responsibilities with respect to end users, business partners and the
+ like. While this license is intended to facilitate the commercial use of
+ the Program, the Contributor who includes the Program in a commercial
+ product offering should do so in a manner which does not create potential
+ liability for other Contributors. Therefore, if a Contributor includes the
+ Program in a commercial product offering, such Contributor ("Commercial
+ Contributor") hereby agrees to defend and indemnify every other
+ Contributor ("Indemnified Contributor") against any losses, damages and
+ costs (collectively "Losses") arising from claims, lawsuits and other
+ legal actions brought by a third party against the Indemnified Contributor
+ to the extent caused by the acts or omissions of such Commercial
+ Contributor in connection with its distribution of the Program in a
+ commercial product offering. The obligations in this section do not apply
+ to any claims or Losses relating to any actual or alleged intellectual
+ property infringement. In order to qualify, an Indemnified Contributor
+ must: a) promptly notify the Commercial Contributor in writing of such
+ claim, and b) allow the Commercial Contributor to control, and cooperate
+ with the Commercial Contributor in, the defense and any related settlement
+ negotiations. The Indemnified Contributor may participate in any such
+ claim at its own expense.</FONT>
+ <P><FONT size=2></FONT>
+ <P><FONT size=2>For example, a Contributor might include the Program in a
+ commercial product offering, Product X. That Contributor is then a
+ Commercial Contributor. If that Commercial Contributor then makes
+ performance claims, or offers warranties related to Product X, those
+ performance claims and warranties are such Commercial Contributor's
+ responsibility alone. Under this section, the Commercial Contributor would
+ have to defend claims against the other Contributors related to those
+ performance claims and warranties, and if a court requires any other
+ Contributor to pay any damages as a result, the Commercial Contributor
+ must pay those damages.</FONT>
+ <P><FONT size=2><FONT color=#0000ff></FONT></FONT>
+ <P><FONT size=2><FONT color=#0000ff></FONT></FONT><FONT size=2><B>5. NO
+ WARRANTY</B></FONT>
+ <P><FONT size=2>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE
+ PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
+ WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
+ FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is</FONT><FONT size=2>
+ solely responsible for determining the appropriateness of using and
+ distributing </FONT><FONT size=2>the Program</FONT><FONT size=2> and
+ assumes all risks associated with its exercise of rights under this
+ Agreement</FONT><FONT size=2>, including but not limited to the risks and
+ costs of program errors, compliance with applicable laws, damage to or
+ loss of data, </FONT><FONT size=2>programs or equipment, and
+ unavailability or interruption of operations</FONT><FONT size=2>.
+ </FONT><FONT size=2></FONT>
+ <P><FONT size=2></FONT>
+ <P><FONT size=2></FONT><FONT size=2><B>6. DISCLAIMER OF
+ LIABILITY</B></FONT>
+ <P><FONT size=2></FONT><FONT size=2>EXCEPT AS EXPRESSLY SET FORTH IN THIS
+ AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+ DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</FONT>
+ <P><FONT size=2></FONT><FONT size=2></FONT>
+ <P><FONT size=2><B>7. GENERAL</B></FONT>
+ <P><FONT size=2></FONT><FONT size=2>If any provision of this Agreement is
+ invalid or unenforceable under applicable law, it shall not affect the
+ validity or enforceability of the remainder of the terms of this
+ Agreement, and without further action by the parties hereto, such
+ provision shall be reformed to the minimum extent necessary to make such
+ provision valid and enforceable.</FONT>
+ <P><FONT size=2></FONT>
+ <P><FONT size=2>If Recipient institutes patent litigation against a
+ Contributor with respect to a patent applicable to software (including a
+ cross-claim or counterclaim in a lawsuit), then any patent licenses
+ granted by that Contributor to such Recipient under this Agreement shall
+ terminate as of the date such litigation is filed. In addition, If
+ Recipient institutes patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Program itself
+ (excluding combinations of the Program with other software or hardware)
+ infringes such Recipient's patent(s), then such Recipient's rights granted
+ under Section 2(b) shall terminate as of the date such litigation is
+ filed. </FONT><FONT size=2></FONT>
+ <P><FONT size=2></FONT>
+ <P><FONT size=2>All Recipient's rights under this Agreement shall
+ terminate if it fails to comply with any of the material terms or
+ conditions of this Agreement and does not cure such failure in a
+ reasonable period of time after becoming aware of such noncompliance. If
+ all Recipient's rights under this Agreement terminate, Recipient agrees to
+ cease use and distribution of the Program as soon as reasonably
+ practicable. However, Recipient's obligations under this Agreement and any
+ licenses granted by Recipient relating to the Program shall continue and
+ survive. </FONT><FONT size=2></FONT>
+ <P><FONT size=2></FONT>
+ <P><FONT size=2></FONT><FONT size=2>IBM may publish new versions
+ (including revisions) of this Agreement from time to time. Each new
+ version of the Agreement will be given a distinguishing version number.
+ The Program (including Contributions) may always be distributed subject to
+ the version of the Agreement under which it was received. In addition,
+ after a new version of the Agreement is published, Contributor may elect
+ to distribute the Program (including its Contributions) under the new
+ version. No one other than IBM has the right to modify this
+ Agreement</FONT><FONT size=2>. </FONT><FONT size=2>Except as expressly
+ stated in Sections 2(a) and 2(b) above, Recipient receives no rights or
+ licenses to the intellectual property of any Contributor under this
+ Agreement, whether expressly, </FONT><FONT size=2>by implication, estoppel
+ or otherwise</FONT><FONT size=2>.</FONT><FONT size=2> All rights in the
+ Program not expressly granted under this Agreement are reserved.</FONT>
+ <P><FONT size=2></FONT>
+ <P><FONT size=2>This Agreement is governed by the laws of the State of New
+ York and the intellectual property laws of the United States of America.
+ No party to this Agreement will bring a legal action under this Agreement
+ more than one year after the cause of action arose.</FONT><FONT size=2>
+ Each party waives its rights to a jury trial in any resulting litigation.
+ </FONT></P></FONT></TD></TR></TBODY></TABLE></BODY></HTML>
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/InstancesOfTypeCollector.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/InstancesOfTypeCollector.java
new file mode 100644
index 000000000..a3e23efa3
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/InstancesOfTypeCollector.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.ui.leaktest;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.jdt.ui.leaktest.reftracker.ReferenceVisitor;
+import org.eclipse.jdt.ui.leaktest.reftracker.ReferencedObject;
+
+/**
+ * An implementation of a {@link ReferenceVisitor} that collects all instances of a given type.
+ * All matches are stored as {@link ReferenceInfo}
+ */
+public class InstancesOfTypeCollector extends ReferenceVisitor {
+
+ private final ArrayList fResults;
+ private int fMatchCount= 0;
+ private long fInstanceCount= 0;
+ private final boolean fIncludeSubtypes;
+ private final String fRequestedTypeName;
+
+ public InstancesOfTypeCollector(String requestedTypeName, boolean includeSubtypes) {
+ fIncludeSubtypes= includeSubtypes;
+ fResults= new ArrayList();
+
+ fMatchCount= 0;
+
+ fRequestedTypeName= requestedTypeName;
+ }
+
+ public ReferenceInfo[] getResults() {
+ return (ReferenceInfo[]) fResults.toArray(new ReferenceInfo[fResults.size()]);
+ }
+
+ public String getResultString() {
+ int i= 0;
+ StringBuffer buf= new StringBuffer();
+ for (Iterator iterator= fResults.iterator(); iterator.hasNext();) {
+ ReferenceInfo element= (ReferenceInfo) iterator.next();
+ buf.append("Element ").append(i++).append('\n');
+ buf.append(element.toString()).append('\n');
+ }
+ return buf.toString();
+ }
+
+ public int getNumberOfResults() {
+ return fResults.size();
+ }
+
+ public boolean visit(ReferencedObject reference, Class clazz, boolean firstVisit) {
+ if (firstVisit) {
+ fInstanceCount++;
+ if (isMatchingType(clazz)) {
+ fMatchCount++;
+ fResults.add(new ReferenceInfo(reference));
+ }
+ }
+ return true;
+ }
+
+ private boolean isMatchingType(Class clazz) {
+ if (clazz.getName().equals(fRequestedTypeName)) {
+ return true;
+ }
+ if (fIncludeSubtypes) {
+ Class superclass= clazz.getSuperclass();
+ if (superclass != null && isMatchingType(superclass)) {
+ return true;
+ }
+ Class[] interfaces= clazz.getInterfaces();
+ for (int i= 0; i < interfaces.length; i++) {
+ if (isMatchingType(interfaces[i])) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/LeakTestCase.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/LeakTestCase.java
new file mode 100644
index 000000000..54d39eded
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/LeakTestCase.java
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.leaktest;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jdt.testplugin.util.DisplayHelper;
+
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.jdt.ui.leaktest.reftracker.ReferenceTracker;
+import org.eclipse.jdt.ui.leaktest.reftracker.ReferenceVisitor;
+import org.eclipse.jdt.ui.leaktest.reftracker.ReferencedObject;
+
+
+/**
+ * Base class for leak test cases.
+ */
+public class LeakTestCase extends TestCase {
+
+ public class MulipleCollectorVisitor extends ReferenceVisitor {
+ private ReferenceVisitor[] fVisitors;
+
+ public MulipleCollectorVisitor(ReferenceVisitor[] visitors) {
+ fVisitors= visitors;
+ }
+
+ public boolean visit(ReferencedObject object, Class clazz, boolean firstVisit) {
+ boolean visitChildren= false;
+ for (int i= 0; i < fVisitors.length; i++) {
+ boolean res= fVisitors[i].visit(object, clazz, firstVisit);
+ visitChildren |= res;
+ }
+ return visitChildren;
+ }
+
+ }
+
+ public LeakTestCase(String name) {
+ super(name);
+ }
+
+ private InstancesOfTypeCollector collect(String requestedTypeName) {
+ InstancesOfTypeCollector requestor= new InstancesOfTypeCollector(requestedTypeName, false);
+ calmDown();
+ new ReferenceTracker(requestor).start(getClass().getClassLoader());
+ return requestor;
+ }
+
+ private InstancesOfTypeCollector[] collect(String[] requestedTypeNames) {
+ final InstancesOfTypeCollector[] requestors= new InstancesOfTypeCollector[requestedTypeNames.length];
+ for (int i= 0; i < requestors.length; i++) {
+ requestors[i]= new InstancesOfTypeCollector(requestedTypeNames[i], false);
+ }
+ calmDown();
+ ReferenceVisitor visitor= new ReferenceVisitor() {
+ public boolean visit(ReferencedObject object, Class clazz, boolean firstVisit) {
+ for (int i= 0; i < requestors.length; i++) {
+ requestors[i].visit(object, clazz, firstVisit);
+ }
+ return true;
+ }
+ };
+
+ new ReferenceTracker(visitor).start(getClass().getClassLoader());
+ return requestors;
+ }
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ * @since 3.4
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ // Ensure active page to allow test being run
+ IWorkbenchWindow activeWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (activeWindow.getActivePage() == null) {
+ activeWindow.openPage(null);
+ }
+ }
+
+ private void calmDown() {
+ // Make sure we wait > 500, to allow e.g. TextViewer.queuePostSelectionChanged(boolean)
+ // and OpenStrategy to time out and release references in delayed runnables.
+ new DisplayHelper() {
+ protected boolean condition() {
+ return false;
+ }
+ }.waitForCondition(Display.getCurrent(), 1000);
+
+ for (int i= 0; i < 10; i++) {
+ System.gc();
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+
+ /**
+ * Asserts that the instance count of the given class is as expected.
+ *
+ * @param clazz the class of the instances to count
+ * @param expected the expected instance count
+ */
+ public void assertInstanceCount(final Class clazz, final int expected) {
+ int numTries= 2;
+ while (true) {
+ InstancesOfTypeCollector requestor= collect(clazz.getName());
+ int actual= requestor.getNumberOfResults();
+ if (expected == actual) {
+ return;
+ }
+ numTries--;
+ if (numTries == 0) {
+ assertTrue("Expected: " + expected + ", actual: " + actual + "\n" + requestor.getResultString(), false);
+ }
+ }
+ }
+
+
+ /**
+ * Asserts that the instance count of the given class is as expected.
+ *
+ * @param classNames the types names of the instances to count
+ * @param expected the expected instance count
+ */
+ public void assertInstanceCount(final String[] classNames, final int[] expected) {
+ int numTries= 2;
+ while (true) {
+ InstancesOfTypeCollector[] requestors= collect(classNames);
+
+ boolean success= true;
+ for (int k= 0; success && k < requestors.length; k++) {
+ if (expected[k] != requestors[k].getNumberOfResults()) {
+ success= false;
+ }
+ }
+ if (success)
+ return;
+
+ numTries--;
+ if (numTries == 0) {
+ StringBuffer buf= new StringBuffer();
+ for (int k= 0; k < requestors.length; k++) {
+ int actual= requestors[k].getNumberOfResults();
+ if (expected[k] != actual) {
+ buf.append("Expected: " + expected[k] + ", actual: " + actual + "\n" + requestors[k].getResultString()).append("\n---------------------\n");
+ }
+ }
+ assertTrue(buf.toString(), false);
+ }
+ }
+ }
+
+ /**
+ * Returns the number of instances of a given class that are live (not garbage).
+ * @param clazz The class of the instances to count
+ * @return Returns the current number of instances of the given class or <code>-1</code> if
+ * no connection is established.
+ */
+ protected int getInstanceCount(Class clazz) {
+ InstancesOfTypeCollector requestor= collect(clazz.getName());
+ return requestor.getNumberOfResults();
+ }
+
+ /**
+ * Assert that two counts are different. The method does not fail if the profile connection
+ * has not established (e.g. because profiling is not supported on the given platform)
+ * @param startCount
+ * @param endCount
+ */
+ protected void assertDifferentCount(int startCount, int endCount) {
+ assertDifferentCount(null, startCount, endCount);
+ }
+
+ /**
+ * Assert that two counts are different. The method does not fail if the profile connection
+ * has not established (e.g. because profiling is not supported on the given platform)
+ * @param message Message to be printed if the test fails.
+ * @param startCount
+ * @param endCount
+ */
+ protected void assertDifferentCount(String message, int startCount, int endCount) {
+ if (startCount == endCount) {
+ String str= message != null ? message + ": " : "";
+ assertTrue(str + "instance count is not different: (" + startCount + " / " + endCount + " )", false);
+ }
+ }
+
+ /**
+ * Assert that two counts are equal. The method does not fail if the profile connection
+ * has not established (e.g. because profiling is not supported on the given platform)
+ * @param startCount
+ * @param endCount
+ */
+ protected void assertEqualCount(int startCount, int endCount) {
+ assertEqualCount(null, startCount, endCount);
+ }
+
+ /**
+ * Assert that two counts are equal. The method does not fail if the profile connection
+ * has not established (e.g. because profiling is not supported on the given platform)
+ * @param message Message to be printed if the test fails.
+ * @param startCount
+ * @param endCount
+ */
+ protected void assertEqualCount(String message, int startCount, int endCount) {
+ if (startCount != endCount) {
+ // only compare if connection could be established
+ String str= message != null ? message + ": " : "";
+ assertTrue(str + "instance count is not the same: (" + startCount + " / " + endCount + " )", false);
+ }
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/LeakTestSetup.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/LeakTestSetup.java
new file mode 100644
index 000000000..c4b2346d2
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/LeakTestSetup.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.leaktest;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+/**
+ *
+ */
+public class LeakTestSetup extends TestSetup {
+
+ private static LeakTestSetup fgCurrentSetup= null;
+
+ public LeakTestSetup(Test test) {
+ super(test);
+ if (fgCurrentSetup == null) {
+ fgCurrentSetup= this;
+ }
+ }
+
+ protected void setUp() throws Exception {
+ if (fgCurrentSetup != this) {
+ return;
+ }
+ // nothing done at the moment
+ }
+
+ protected void tearDown() throws Exception {
+ if (fgCurrentSetup != this) {
+ return;
+ }
+ // nothing done at the moment
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/ReferenceInfo.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/ReferenceInfo.java
new file mode 100644
index 000000000..3fadd376c
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/ReferenceInfo.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.ui.leaktest;
+
+import java.util.ArrayList;
+
+import org.eclipse.jdt.ui.leaktest.reftracker.ReferencedArrayElement;
+import org.eclipse.jdt.ui.leaktest.reftracker.ReferencedFieldElement;
+import org.eclipse.jdt.ui.leaktest.reftracker.ReferencedObject;
+
+/**
+ * Result element with information to the link to the root element
+ *
+ */
+
+public class ReferenceInfo {
+
+ private Object fReference;
+ private BacklinkNode[] fBacklinkNodes;
+ private boolean fIsPosibleLeak;
+
+ public ReferenceInfo(ReferencedObject ref) {
+ fReference= ref.getValue();
+ fBacklinkNodes= getBacklinkNodes(ref);
+ }
+
+ public boolean isPosibleLeak() {
+ return fIsPosibleLeak;
+ }
+
+ public void setPosibleLeak(boolean isPosibleLeak) {
+ fIsPosibleLeak= isPosibleLeak;
+ }
+
+ private BacklinkNode[] getBacklinkNodes(ReferencedObject curr) {
+ ArrayList res= new ArrayList();
+
+ while (curr != null) {
+ String str;
+ if (curr instanceof ReferencedArrayElement) {
+ ReferencedArrayElement ref= (ReferencedArrayElement) curr;
+ String name= ref.getReferenceHolder().getValue().getClass().getComponentType().getName();
+ str= name + String.valueOf('[') + ref.getIndex() + String.valueOf(']');
+ } else if (curr instanceof ReferencedFieldElement) {
+ ReferencedFieldElement ref= (ReferencedFieldElement) curr;
+ String name= ref.getField().getDeclaringClass().getName();
+ str= name + "#" + ref.getField().getName();
+ } else {
+ str= curr.getValue().getClass().getName();
+ }
+ res.add(new BacklinkNode(str, curr.getValue()));
+ curr= curr.getReferenceHolder();
+ }
+ return (BacklinkNode[]) res.toArray(new BacklinkNode[res.size()]);
+ }
+
+ public Object getReference() {
+ return fReference;
+ }
+
+ public BacklinkNode[] getBacklinkNodes() {
+ return fBacklinkNodes;
+ }
+
+ public String toString() {
+ StringBuffer buf= new StringBuffer();
+ buf.append(getReference().getClass().getName()).append('\n');
+ BacklinkNode[] backlinkNodes= getBacklinkNodes();
+ for (int i= 0; i < backlinkNodes.length; i++) {
+ buf.append(" ").append(backlinkNodes[i].getBackLinkString());
+ String value= backlinkNodes[i].getValue().toString();
+ if (value.length() > 100)
+ value= value.substring(0, 99);
+ buf.append(" -> ").append(value).append('\n');
+ }
+ return buf.toString();
+ }
+
+ private static class BacklinkNode {
+
+ private Object fValue;
+ private final String fBackStrings;
+
+ public BacklinkNode(String str, Object value) {
+ fBackStrings= str;
+ fValue= value;
+ }
+
+ public String getBackLinkString() {
+ return fBackStrings;
+ }
+
+ public Object getValue() {
+ return fValue;
+ }
+
+ }
+
+}
+
+
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/example/LeakTestExample.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/example/LeakTestExample.java
new file mode 100644
index 000000000..79cf833cc
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/example/LeakTestExample.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.leaktest.example;
+
+import java.util.ArrayList;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.jdt.ui.leaktest.LeakTestCase;
+import org.eclipse.jdt.ui.leaktest.LeakTestSetup;
+
+
+public class LeakTestExample extends LeakTestCase {
+
+ private static final Class THIS= LeakTestExample.class;
+
+ private static class MyClass {
+ }
+
+
+ public static Test suite() {
+ return new LeakTestSetup(new TestSuite(THIS));
+ }
+
+ private Object fGlobalReference;
+
+ private ArrayList fGlobalList= new ArrayList();
+
+ public LeakTestExample(String name) {
+ super(name);
+ }
+
+ public void testLeakGlobalReference() throws Exception {
+ fGlobalList.clear();
+
+ Class cl= MyClass.class;
+
+ // get the count before creating the instance
+ int count1= getInstanceCount(cl);
+
+ // create the instance
+ fGlobalReference= new MyClass();
+
+ // get the count after creating the instance
+ int count2= getInstanceCount(cl);
+ assertDifferentCount("after creation: ", count1, count2);
+
+ // clear all references to the instance
+ fGlobalReference= null;
+
+ // get the count after clearing the reference of the instance
+ int count3= getInstanceCount(cl);
+ assertEqualCount("after clear: ", count1, count3);
+ }
+
+ public void testNoLeakGlobalReference() throws Exception {
+ fGlobalList.clear();
+ Class cl= MyClass.class;
+
+ // get the count before creating my instance
+ int count1= getInstanceCount(cl);
+
+ // create the instance
+ fGlobalReference= new MyClass();
+
+ // get the count after creating the instance
+ int count2= getInstanceCount(cl);
+ assertDifferentCount("after creation: ", count1, count2);
+
+ // add the instance to a list
+ fGlobalList.add(fGlobalReference);
+
+ // clear the global references of the instance
+ fGlobalReference= null;
+
+ // get the count after clearing the global reference of the instance
+ // instance should still be here, it is referenced in the list
+ int count3= getInstanceCount(cl);
+ assertEqualCount("after clear: ", count2, count3);
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/FIFOQueue.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/FIFOQueue.java
new file mode 100644
index 000000000..e7280bf7c
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/FIFOQueue.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.ui.leaktest.reftracker;
+
+import java.util.Arrays;
+
+
+public class FIFOQueue {
+
+ private Object[] fStore;
+ private int fReadIndex;
+ private int fWriteIndex;
+
+ public FIFOQueue(int initialSize) {
+ fStore= new Object[initialSize];
+ fReadIndex= 0;
+ fWriteIndex= 0;
+ }
+
+ public void add(Object object) {
+ int pos= fWriteIndex;
+ int next= nextIndex(pos, fStore.length);
+ if (next == fReadIndex) {
+ pos= increaseCapacity();
+ next= pos + 1;
+ }
+ fStore[pos]= object;
+ fWriteIndex= next;
+ }
+
+ private int increaseCapacity() {
+ Object[] oldStore= fStore;
+ int oldLen= oldStore.length;
+ Object[] newStore= new Object[oldLen * 2];
+ int k= 0;
+ for (int i= fReadIndex, end= fWriteIndex; i != end; i= nextIndex(i, oldLen), k++) {
+ newStore[k]= oldStore[i];
+ oldStore[i]= null;
+ }
+ fStore= newStore;
+ fReadIndex= 0;
+ fWriteIndex= k;
+ return k;
+ }
+
+ public Object poll() {
+ if (isEmpty()) {
+ return null;
+ }
+ int index= fReadIndex;
+ Object element= fStore[index];
+ fStore[index]= null; // avoid unnecessary references
+ fReadIndex= nextIndex(index, fStore.length);
+ return element;
+ }
+
+ private static int nextIndex(int index, int max) {
+ int next= index + 1;
+ if (next == max) {
+ return 0;
+ }
+ return next;
+ }
+
+ public boolean isEmpty() {
+ return fReadIndex == fWriteIndex;
+ }
+
+ public int getSize() {
+ if (fReadIndex <= fWriteIndex) {
+ return fWriteIndex - fReadIndex;
+ } else {
+ return fStore.length - fReadIndex + fWriteIndex;
+ }
+ }
+
+ public void clear() {
+ Arrays.fill(fStore, null);
+ fReadIndex= 0;
+ fWriteIndex= 0;
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/IdentityHashSet.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/IdentityHashSet.java
new file mode 100644
index 000000000..134d460a1
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/IdentityHashSet.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.ui.leaktest.reftracker;
+
+import java.util.Arrays;
+
+/**
+ *
+ */
+public class IdentityHashSet {
+
+ private Object[] fObjects;
+ private int fThreshold;
+ private int fSize;
+
+ public IdentityHashSet(int initialSize) {
+ fObjects= new Object[initialSize];
+ fThreshold= getThreshold(initialSize);
+ fSize= 0;
+ }
+
+ private static int getThreshold(int initialSize) {
+ return (initialSize * 5) / 6;
+ }
+
+ public boolean add(Object o) {
+ if (o == null) {
+ throw new IllegalArgumentException("Can not add null"); //$NON-NLS-1$
+ }
+ int insertionIndex= getInsertionIndex(o, fObjects);
+ if (insertionIndex == -1) {
+ return false; // already in set
+ }
+ insertElement(o, insertionIndex);
+ return true;
+ }
+
+ private void insertElement(Object o, int index) {
+ fObjects[index]= o;
+ fSize++;
+ if (fSize > fThreshold) {
+ increaseSize();
+ }
+ }
+
+ private static int getInsertionIndex(Object elem, Object[] elements) {
+ int hash= getHash(elem, elements.length);
+ Object entry= elements[hash];
+ while (entry != null && entry != elem) {
+ hash++;
+ if (hash == elements.length) {
+ hash= 0; // wrap
+ }
+ entry= elements[hash];
+ }
+ if (entry == null) {
+ return hash;
+ }
+ return -1; // already in set
+ }
+
+
+ private void increaseSize() {
+ int newSize= fObjects.length * 2;
+ Object[] newArray= new Object[newSize];
+ for (int i= 0; i < fObjects.length; i++) {
+ Object curr= fObjects[i];
+ if (curr != null) {
+ int insertionIndex= getInsertionIndex(curr, newArray);
+ newArray[insertionIndex]= curr;
+ fObjects[i]= null; // avoid unnecessary references
+ }
+ }
+ fObjects= newArray;
+ fThreshold= getThreshold(newSize);
+ }
+
+ public boolean contains(Object o) {
+ return getInsertionIndex(o, fObjects) == -1;
+ }
+
+ public int size() {
+ return fSize;
+ }
+
+ public void clear() {
+ Arrays.fill(fObjects, null);
+ fSize= 0;
+ }
+
+ /**
+ * Return index for Object x.
+ * @param x the object
+ * @param length the length of the hashtable
+ * @return returns the hash
+ */
+ private static int getHash(Object x, int length) { // copied from IdentityHashMap
+ return System.identityHashCode(x) % length;
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferenceTracker.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferenceTracker.java
new file mode 100644
index 000000000..43bfb03fc
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferenceTracker.java
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.leaktest.reftracker;
+
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
+import org.eclipse.jdt.testplugin.JavaTestPlugin;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * Tracks all instances reachable though reflection from a given root object. To visit all elements in a VM
+ * pass a class loader as class loaders know all loaded classes and classes know all static fields. This normally covers
+ * all references except instances that are only referenced by local variables or by native roots
+ */
+public final class ReferenceTracker {
+
+ private static final String CURRENT_PKG_NAME= ReferenceTracker.class.getPackage().getName();
+ private static final String REFERENCE_NAME= Reference.class.getName();
+
+ private IdentityHashSet fVisitedElements;
+ private final ReferenceVisitor fReferenceVisitor;
+ private FIFOQueue fQueue;
+ private MultiStatus fStatus;
+
+ private boolean fSkipWeakOrSoft;
+
+ public ReferenceTracker(ReferenceVisitor visitor) {
+ fReferenceVisitor= visitor;
+ fStatus= null;
+ fVisitedElements= null;
+ fQueue= null;
+ fSkipWeakOrSoft= true;
+ }
+
+ private static boolean isInteresting(Class clazz) {
+ String name= clazz.getName();
+ if (name.startsWith(CURRENT_PKG_NAME) || name.startsWith("sun.reflect.")) { //$NON-NLS-1$
+ return false;
+ }
+ return true;
+ }
+
+ private void followArrayReference(ReferencedObject prev, int index, Object to) {
+ fQueue.add(new ReferencedArrayElement(prev, index, to));
+ }
+
+ private void followFieldReference(ReferencedObject ref, Object curr, Field fld) {
+ try {
+ if (fSkipWeakOrSoft && isWeakOrSoftReference(curr, fld)) {
+ return;
+ }
+ boolean isAccessible= setAccessible(fld, true);
+ try {
+ Object fieldVal= fld.get(curr);
+ if (fieldVal != null) {
+ fQueue.add(new ReferencedFieldElement(ref, fld, fieldVal));
+ }
+ } finally {
+ setAccessible(fld, isAccessible);
+ }
+ } catch (IllegalArgumentException e) {
+ handleError(e, fld);
+ } catch (IllegalAccessException e) {
+ handleError(e, fld);
+ } catch (ExceptionInInitializerError e) {
+ handleError(e, fld);
+ }
+ }
+
+ private static boolean isWeakOrSoftReference(Object curr, Field fld) {
+ if (REFERENCE_NAME.equals(fld.getDeclaringClass().getName())) {
+ return "referent".equals(fld.getName())
+ && (curr instanceof WeakReference || curr instanceof SoftReference);
+ }
+ return false;
+ }
+
+
+ private void handleError(Throwable t, Field fld) {
+ fStatus.add(new Status(IStatus.ERROR, JavaTestPlugin.getPluginId(), IStatus.ERROR, "Problem on access of " + fld.toString(), t));
+ }
+
+ private void followStaticReferences(Class classInstance) {
+ Field[] declaredFields= classInstance.getDeclaredFields();
+ for (int i= 0; i < declaredFields.length; i++) {
+ Field fld= declaredFields[i];
+ if (isStatic(fld.getModifiers()) && !fld.getType().isPrimitive()) {
+ followFieldReference(new RootReference(classInstance), null, fld);
+ }
+ }
+ }
+
+ private static boolean setAccessible(Field fld, boolean enable) {
+ boolean isAccessible= fld.isAccessible();
+ if (isAccessible != enable) {
+ fld.setAccessible(enable);
+ }
+ return isAccessible;
+ }
+
+ private void visit(ReferencedObject ref) {
+ Object curr= ref.getValue();
+ Class currClass= curr.getClass();
+ if (!isInteresting(currClass)) {
+ return;
+ }
+
+ boolean firstVisit= fVisitedElements.add(curr);
+ boolean continueVisiting= fReferenceVisitor.visit(ref, curr.getClass(), firstVisit);
+
+ if (!firstVisit || !continueVisiting) {
+ return;
+ }
+
+ if (currClass.isArray()) {
+ if (currClass.getComponentType().isPrimitive()) {
+ return;
+ }
+ Object[] array= (Object[]) curr;
+ for (int i= 0; i < array.length; i++) {
+ Object elem= array[i];
+ if (elem != null) {
+ followArrayReference(ref, i, elem);
+ }
+ }
+ } else if (currClass.isPrimitive()) {
+ return;
+ } else {
+ if (currClass == Class.class) {
+ followStaticReferences((Class) curr);
+ }
+ do {
+ Field[] declaredFields= currClass.getDeclaredFields();
+ for (int i= 0; i < declaredFields.length; i++) {
+ Field fld= declaredFields[i];
+ if (!isStatic(fld.getModifiers()) && !fld.getType().isPrimitive()) {
+ followFieldReference(ref, curr, fld);
+ }
+ }
+ currClass= currClass.getSuperclass();
+ } while (currClass != null);
+ }
+ }
+
+ private static boolean isStatic(int modifiers) {
+ return (modifiers & Modifier.STATIC) != 0;
+ }
+
+ public IStatus start(Object root) {
+ fVisitedElements= new IdentityHashSet(1 << 21); // 2 M -> 8 MB
+ fQueue= new FIFOQueue(100);
+ fStatus= new MultiStatus(JavaTestPlugin.getPluginId(), IStatus.OK, "Problem tracking resources", null);
+
+ try {
+ visit(new RootReference(root));
+
+ FIFOQueue queue= fQueue;
+
+ ReferencedObject next= (ReferencedObject) queue.poll();
+ while (next != null) {
+ visit(next);
+ next= (ReferencedObject) queue.poll();
+ }
+ } finally {
+ // make sure not to hold on any references
+ fVisitedElements.clear();
+ fVisitedElements= null;
+ fQueue= null;
+ }
+ return fStatus;
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferenceVisitor.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferenceVisitor.java
new file mode 100644
index 000000000..897e2477b
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferenceVisitor.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.ui.leaktest.reftracker;
+
+
+public class ReferenceVisitor {
+
+ /**
+ * Visits a referenced object
+ * @param object the referenced object
+ * @param clazz the class of the reference object
+ * @param firstVisit if set this is the first visit
+ * @return <code>true</code> if the references from this object should be
+ * visited, and <code>false</code> if the children of this node should
+ * be skipped. If this is not the first visit, children will never be visited, regardless of the
+ * boolean returned.
+ */
+ public boolean visit(ReferencedObject object, Class clazz, boolean firstVisit) {
+ return true;
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferencedArrayElement.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferencedArrayElement.java
new file mode 100644
index 000000000..c38df3033
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferencedArrayElement.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.ui.leaktest.reftracker;
+
+
+/**
+ *
+ */
+public class ReferencedArrayElement extends ReferencedObject {
+
+ private final ReferencedObject fPrevious;
+ private final int fIndex;
+
+ public ReferencedArrayElement(ReferencedObject previous, int index, Object value) {
+ super(value);
+ fPrevious= previous;
+ fIndex= index;
+ }
+
+ public ReferencedObject getReferenceHolder() {
+ return fPrevious;
+ }
+
+ public int getIndex() {
+ return fIndex;
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferencedFieldElement.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferencedFieldElement.java
new file mode 100644
index 000000000..bc8a9933a
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferencedFieldElement.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.ui.leaktest.reftracker;
+
+import java.lang.reflect.Field;
+
+
+/**
+ *
+ */
+public class ReferencedFieldElement extends ReferencedObject {
+
+ private final ReferencedObject fPrevious;
+ private final Field fField;
+
+ public ReferencedFieldElement(ReferencedObject previous, Field field, Object value) {
+ super(value);
+ fPrevious= previous;
+ fField= field;
+ }
+
+ public ReferencedObject getReferenceHolder() {
+ return fPrevious;
+ }
+
+ public Field getField() {
+ return fField;
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferencedObject.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferencedObject.java
new file mode 100644
index 000000000..c4c61a955
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferencedObject.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.ui.leaktest.reftracker;
+
+/**
+ * Represents an object that is referenced by an other object.
+ */
+public abstract class ReferencedObject {
+
+ private final Object fReferenced;
+
+ public ReferencedObject(Object object) {
+ fReferenced= object;
+ }
+
+ /**
+ * Returns the instance that keeps a reference to the current object or <code>null</code>
+ * if the element is a root element
+ * @return returns the instance that keeps a reference to the current object or <code>null</code>
+ * if the element is a root element
+ */
+ public abstract ReferencedObject getReferenceHolder();
+
+ /**
+ * Returns the object
+ * @return returns the object
+ */
+ public Object getValue() {
+ return fReferenced;
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/RootReference.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/RootReference.java
new file mode 100644
index 000000000..1be876444
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/RootReference.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.ui.leaktest.reftracker;
+
+public class RootReference extends ReferencedObject {
+
+ public RootReference(Object object) {
+ super(object);
+ }
+
+ public ReferencedObject getReferenceHolder() {
+ return null;
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/JavaLeakTest.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/JavaLeakTest.java
new file mode 100644
index 000000000..0963e2916
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/JavaLeakTest.java
@@ -0,0 +1,398 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.leaks;
+
+import java.io.ByteArrayInputStream;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.jdt.testplugin.JavaProjectHelper;
+import org.eclipse.jdt.testplugin.util.DisplayHelper;
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IPerspectiveDescriptor;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.handlers.IHandlerService;
+
+import org.eclipse.ui.editors.text.TextEditor;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+
+import org.eclipse.jdt.ui.leaktest.LeakTestCase;
+import org.eclipse.jdt.ui.leaktest.LeakTestSetup;
+
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor;
+import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
+import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
+import org.eclipse.jdt.internal.ui.wizards.JavaProjectWizard;
+import org.eclipse.jdt.internal.ui.wizards.NewClassCreationWizard;
+import org.eclipse.jdt.internal.ui.wizards.NewInterfaceCreationWizard;
+
+public class JavaLeakTest extends LeakTestCase {
+
+ private IJavaProject fJProject;
+
+ private static final Class THIS= JavaLeakTest.class;
+
+ public JavaLeakTest(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ if (true) {
+ return new LeakTestSetup(new TestSuite(THIS));
+ } else {
+ TestSuite suite= new TestSuite();
+ suite.addTest(new JavaLeakTest("testJavaEditorActionDelegate"));
+ return new LeakTestSetup(suite);
+ }
+ }
+
+ public static Test setUpTest(Test test) {
+ return new LeakTestSetup(test);
+ }
+
+ public void testTextEditorClose() throws Exception {
+ IFile file= createTestFile("Test.txt");
+ internalTestEditorClose(file, TextEditor.class, false);
+ }
+
+ public void testTextEditorCloseOneOfTwo() throws Exception {
+ IFile file1= createTestFile("Test1.txt");
+ IEditorPart editor1= EditorUtility.openInEditor(file1);
+ assertEquals(editor1.getClass(), TextEditor.class);
+ assertInstanceCount(TextEditor.class, 1);
+
+ IFile file2= createTestFile("Test2.txt");
+ IEditorPart editor2= EditorUtility.openInEditor(file2);
+ assertEquals(editor2.getClass(), TextEditor.class);
+ assertInstanceCount(TextEditor.class, 2);
+
+ assertTrue("Could not close editor", JavaPlugin.getActivePage().closeEditor(editor2, false));
+ editor2= null;
+
+ assertInstanceCount(TextEditor.class, 1);
+
+ assertTrue("Could not close editor", JavaPlugin.getActivePage().closeEditor(editor1, false));
+ editor1= null;
+
+ assertInstanceCount(TextEditor.class, 0);
+ }
+
+ public void testTextEditorCloseAll() throws Exception {
+ IFile file= createTestFile("Test.txt");
+ internalTestEditorClose(file, TextEditor.class, true);
+ }
+
+ public void testJavaEditorClose() throws Exception {
+ ICompilationUnit cu= createTestCU("Test");
+ internalTestEditorClose(cu, CompilationUnitEditor.class, false);
+ }
+
+ public void testJavaEditorCloseOneOfTwo() throws Exception {
+ ICompilationUnit cu1= createTestCU("Test1");
+ IEditorPart editor1= EditorUtility.openInEditor(cu1);
+ assertEquals(editor1.getClass(), CompilationUnitEditor.class);
+ assertInstanceCount(CompilationUnitEditor.class, 1);
+
+ ICompilationUnit cu2= createTestCU("Test2");
+ IEditorPart editor2= EditorUtility.openInEditor(cu2);
+ assertEquals(editor2.getClass(), CompilationUnitEditor.class);
+ assertInstanceCount(CompilationUnitEditor.class, 2);
+
+ assertTrue("Could not close editor", JavaPlugin.getActivePage().closeEditor(editor2, false));
+ editor2= null;
+
+ assertInstanceCount(CompilationUnitEditor.class, 1);
+
+ assertTrue("Could not close editor", JavaPlugin.getActivePage().closeEditor(editor1, false));
+ editor1= null;
+
+ assertInstanceCount(CompilationUnitEditor.class, 0);
+ }
+
+ public void testJavaEditorCloseAll() throws Exception {
+ ICompilationUnit cu= createTestCU("Test");
+ internalTestEditorClose(cu, CompilationUnitEditor.class, true);
+ }
+
+ public void testJavaEditorBreadcrumbCloseAll() throws Exception {
+ try {
+ JavaPlugin.getDefault().getPreferenceStore().setValue(getBreadcrumbPreferenceKey(), true);
+ ICompilationUnit cu= createTestCU("Test");
+ internalTestEditorClose(cu, CompilationUnitEditor.class, true, true);
+ } finally {
+ JavaPlugin.getDefault().getPreferenceStore().setValue(getBreadcrumbPreferenceKey(), false);
+ }
+ }
+
+ public void testJavaEditorBreadcrumbClose() throws Exception {
+ try {
+ JavaPlugin.getDefault().getPreferenceStore().setValue(getBreadcrumbPreferenceKey(), true);
+ ICompilationUnit cu= createTestCU("Test");
+ internalTestEditorClose(cu, CompilationUnitEditor.class, false, true);
+ } finally {
+ JavaPlugin.getDefault().getPreferenceStore().setValue(getBreadcrumbPreferenceKey(), false);
+ }
+ }
+
+ public void testJavaEditorBreadcrumbCloseOneOfTwo1() throws Exception {
+ try {
+ JavaPlugin.getDefault().getPreferenceStore().setValue(getBreadcrumbPreferenceKey(), true);
+ ICompilationUnit cu1= createTestCU("Test1");
+ IEditorPart editor1= EditorUtility.openInEditor(cu1);
+ assertEquals(editor1.getClass(), CompilationUnitEditor.class);
+ activateBreadcrumb((JavaEditor) editor1);
+ assertInstanceCount(CompilationUnitEditor.class, 1);
+
+ ICompilationUnit cu2= createTestCU("Test2");
+ IEditorPart editor2= EditorUtility.openInEditor(cu2);
+ assertEquals(editor2.getClass(), CompilationUnitEditor.class);
+ activateBreadcrumb((JavaEditor) editor2);
+ assertInstanceCount(CompilationUnitEditor.class, 2);
+
+ assertTrue("Could not close editor", JavaPlugin.getActivePage().closeEditor(editor2, false));
+ editor2= null;
+
+ assertInstanceCount(CompilationUnitEditor.class, 1);
+
+ assertTrue("Could not close editor", JavaPlugin.getActivePage().closeEditor(editor1, false));
+ editor1= null;
+
+ assertInstanceCount(CompilationUnitEditor.class, 0);
+ } finally {
+ JavaPlugin.getDefault().getPreferenceStore().setValue(getBreadcrumbPreferenceKey(), false);
+ }
+ }
+
+ public void testJavaEditorBreadcrumbCloseOneOfTwo2() throws Exception {
+ try {
+ JavaPlugin.getDefault().getPreferenceStore().setValue(getBreadcrumbPreferenceKey(), true);
+ ICompilationUnit cu1= createTestCU("Test1");
+ IEditorPart editor1= EditorUtility.openInEditor(cu1);
+ assertEquals(editor1.getClass(), CompilationUnitEditor.class);
+ assertInstanceCount(CompilationUnitEditor.class, 1);
+
+ ICompilationUnit cu2= createTestCU("Test2");
+ IEditorPart editor2= EditorUtility.openInEditor(cu2);
+ assertEquals(editor2.getClass(), CompilationUnitEditor.class);
+ activateBreadcrumb((JavaEditor) editor2);
+ assertInstanceCount(CompilationUnitEditor.class, 2);
+
+ assertTrue("Could not close editor", JavaPlugin.getActivePage().closeEditor(editor2, false));
+ editor2= null;
+
+ assertInstanceCount(CompilationUnitEditor.class, 1);
+
+ assertTrue("Could not close editor", JavaPlugin.getActivePage().closeEditor(editor1, false));
+ editor1= null;
+
+ assertInstanceCount(CompilationUnitEditor.class, 0);
+ } finally {
+ JavaPlugin.getDefault().getPreferenceStore().setValue(getBreadcrumbPreferenceKey(), false);
+ }
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ fJProject= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ assertTrue("RT not found", JavaProjectHelper.addRTJar(fJProject) != null);
+ assertTrue(JavaPlugin.getActivePage().closeAllEditors(false));
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ JavaProjectHelper.delete(fJProject);
+ }
+
+ private ICompilationUnit createTestCU(String typeName) throws Exception {
+ IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject, "src");
+
+ IPackageFragment pack2= sourceFolder.createPackageFragment("pack0", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package pack0;\n");
+ buf.append("public class " + typeName + " {\n}\n");
+ return pack2.createCompilationUnit(typeName + ".java", buf.toString(), false, null);
+ }
+
+ private IFile createTestFile(String fileName) throws Exception {
+ IProject project= fJProject.getProject();
+ IFile file= project.getFile(fileName);
+ file.create(new ByteArrayInputStream("test\n".getBytes(project.getDefaultCharset())), false, null);
+ assertTrue(file.exists());
+ return file;
+ }
+
+ private void internalTestEditorClose(Object objectToOpen, final Class clazz, boolean closeAll) throws Exception {
+ internalTestEditorClose(objectToOpen, clazz, closeAll, false);
+ }
+
+ private void internalTestEditorClose(Object objectToOpen, final Class clazz, boolean closeAll, boolean activateBreadcrumb) throws Exception {
+ IEditorPart part= internalTestEditorOpen(objectToOpen, clazz);
+
+ if (activateBreadcrumb && part instanceof JavaEditor) {
+ activateBreadcrumb((JavaEditor) part);
+ }
+
+ // can't close and assert abandonment in a separate method, since that would leave 'part' as a stack-local reference
+ boolean res;
+ if (closeAll)
+ res= JavaPlugin.getActivePage().closeAllEditors(false);
+ else
+ res= JavaPlugin.getActivePage().closeEditor(part, false);
+ part= null;
+ assertTrue("Could not close editor", res);
+
+ // verify that the editor instance is gone
+ assertInstanceCount(clazz, 0);
+ }
+
+ private void activateBreadcrumb(JavaEditor editor) {
+ editor.getBreadcrumb().activate();
+ DisplayHelper.sleep(editor.getSite().getShell().getDisplay(), 10 * 1000);
+ }
+
+ private IEditorPart internalTestEditorOpen(Object objectToOpen, final Class clazz) throws PartInitException {
+ // verify that no instance is there when we start
+ assertInstanceCount(clazz, 0);
+
+ // open an editor on given object
+ IEditorPart part= EditorUtility.openInEditor(objectToOpen);
+
+ // make sure the received instance has the type we're expecting
+ assertEquals(part.getClass(), clazz);
+
+ // verify that the editor instance is there
+ assertInstanceCount(clazz, 1);
+ return part;
+ }
+
+ public void testNewClassWizard() throws Exception {
+ assertInstanceCount(NewClassCreationWizard.class, 0);
+ doWizardLeakTest(new NewClassCreationWizard());
+ assertInstanceCount(NewClassCreationWizard.class, 0);
+ }
+
+ public void testNewInterfaceWizard() throws Exception {
+ assertInstanceCount(NewInterfaceCreationWizard.class, 0);
+ doWizardLeakTest(new NewInterfaceCreationWizard());
+ assertInstanceCount(NewInterfaceCreationWizard.class, 0);
+ }
+
+ public void testNewJavaProjectWizard() throws Exception {
+ assertInstanceCount(JavaProjectWizard.class, 0);
+ doWizardLeakTest(new JavaProjectWizard());
+ assertInstanceCount(JavaProjectWizard.class, 0);
+ }
+
+ private void doWizardLeakTest(INewWizard wizard) throws Exception {
+ wizard.init(JavaPlugin.getDefault().getWorkbench(), new StructuredSelection(fJProject));
+
+ Shell shell= JavaPlugin.getActiveWorkbenchShell();
+ WizardDialog dialog= new WizardDialog(shell, wizard);
+ dialog.setBlockOnOpen(false);
+ dialog.create();
+ dialog.open();
+
+ dialog.close();
+ wizard= null;
+ dialog= null;
+ }
+
+ public void testJavaEditorContextMenu() throws Exception {
+ //regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=166761
+
+ ICompilationUnit cu= createTestCU("Test");
+ IEditorPart part= internalTestEditorOpen(cu, CompilationUnitEditor.class);
+
+ final Menu menu= ((CompilationUnitEditor) part).getViewer().getTextWidget().getMenu();
+ openContextMenu(menu);
+
+ boolean res= JavaPlugin.getActivePage().closeEditor(part, false);
+ part= null;
+ assertTrue("Could not close editor", res);
+
+ // verify that the editor instance is gone
+ assertInstanceCount(CompilationUnitEditor.class, 0);
+ }
+
+ private void openContextMenu(final Menu menu) {
+ Display display= menu.getDisplay();
+
+ while (!menu.isDisposed() && display.readAndDispatch()) {
+ //loop, don't sleep
+ }
+
+ menu.setVisible(true);
+
+ display.asyncExec(new Runnable() {
+ public void run() {
+ menu.setVisible(false);
+ }
+ });
+
+ while (!menu.isDisposed() && display.readAndDispatch()) {
+ //loop, don't sleep
+ }
+ }
+
+ public void testJavaEditorActionDelegate() throws Exception {
+ //regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=166761
+
+ ICompilationUnit cu= createTestCU("Test");
+ IEditorPart part= internalTestEditorOpen(cu, CompilationUnitEditor.class);
+
+ IWorkbenchWindow workbenchWindow= part.getSite().getWorkbenchWindow();
+ Shell shell= workbenchWindow.getShell();
+ shell.forceActive();
+ // run display loop, such that GTK can send shell activate events, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=286244
+ DisplayHelper.sleep(shell.getDisplay(), 5000);
+
+ IWorkbench workbench= workbenchWindow.getWorkbench();
+ part.getEditorSite().getPage().activate(part);
+ IHandlerService handlerService= (IHandlerService) workbench.getService(IHandlerService.class);
+ handlerService.executeCommand("org.eclipse.jdt.ui.tests.JavaLeakTestActionDelegate", null);
+
+ boolean res= JavaPlugin.getActivePage().closeEditor(part, false);
+ part= null;
+ assertTrue("Could not close editor", res);
+
+ // verify that the editor instance is gone
+ assertInstanceCount(CompilationUnitEditor.class, 0);
+ }
+
+ private String getBreadcrumbPreferenceKey() {
+ IPerspectiveDescriptor perspective= JavaPlugin.getActivePage().getPerspective();
+ if (perspective == null)
+ return null;
+ return JavaEditor.EDITOR_SHOW_BREADCRUMB + "." + perspective.getId(); //$NON-NLS-1$
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/JavaLeakTestActionDelegate.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/JavaLeakTestActionDelegate.java
new file mode 100644
index 000000000..1e9d6c269
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/JavaLeakTestActionDelegate.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.leaks;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+
+import org.eclipse.ui.IEditorActionDelegate;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+public class JavaLeakTestActionDelegate implements IWorkbenchWindowActionDelegate, IEditorActionDelegate {
+
+ public IWorkbenchWindow fWindow;
+ public IEditorPart fEditor;
+
+ public JavaLeakTestActionDelegate() {
+
+ }
+
+ public void init(IWorkbenchWindow window) {
+ fWindow= window;
+ }
+
+ public void setActiveEditor(IAction action, IEditorPart targetEditor) {
+ fEditor= targetEditor;
+ }
+
+ public void run(IAction action) {
+ System.out.println("running JavaLeakTestActionDelegate");
+ }
+
+ public void dispose() {
+ fWindow= null;
+ fEditor= null;
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/LeakTestSuite.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/LeakTestSuite.java
new file mode 100644
index 000000000..bc5732328
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/LeakTestSuite.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.leaks;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+
+/**
+ * Test for leaks
+ */
+//{ObjectTeams: moved here from org.eclipse.jdt.ui.tests to please the report generator SH}
+public class LeakTestSuite extends TestSuite {
+
+ /**
+ * Returns the suite. This is required to
+ * use the JUnit Launcher.
+ *
+ * @return the test suite.
+ */
+ public static Test suite() {
+ return new LeakTestSuite();
+ }
+
+ /**
+ * Construct the test suite.
+ */
+ public LeakTestSuite() {
+ addTest(JavaLeakTest.suite());
+ addTest(SearchLeakTestWrapper.suite());
+ addTest(UndoManagerLeakTest.suite());
+ addTest(TextViewerUndoManagerLeakTest.suite());
+ }
+
+}
+
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/SearchLeakTest.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/SearchLeakTest.java
new file mode 100644
index 000000000..6f4f29dc0
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/SearchLeakTest.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.leaks;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.search2.internal.ui.InternalSearchUI;
+
+import org.eclipse.jdt.ui.leaktest.LeakTestCase;
+import org.eclipse.jdt.ui.leaktest.LeakTestSetup;
+import org.eclipse.jdt.ui.tests.search.JUnitSourceSetup;
+import org.eclipse.jdt.ui.tests.search.SearchTestHelper;
+
+import org.eclipse.jdt.internal.ui.search.JavaSearchQuery;
+import org.eclipse.jdt.internal.ui.search.JavaSearchResult;
+
+/**
+ */
+//{ObjectTeams: moved here from org.eclipse.jdt.ui.tests.search to please the report generator SH}
+public class SearchLeakTest extends LeakTestCase {
+ public SearchLeakTest(String name) {
+ super(name);
+ }
+
+ public static Test allTests() {
+ return new LeakTestSetup(new JUnitSourceSetup(new TestSuite(SearchLeakTest.class)));
+ }
+
+ public static Test suite() {
+ return allTests();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testRemoveSearchQueries() throws Exception {
+ JavaSearchQuery query1= SearchTestHelper.runMethodRefQuery("junit.framework.Test", "countTestCases", new String[0]);
+ JavaSearchQuery query2= SearchTestHelper.runMethodRefQuery("junit.framework.TestCase", "countTestCases", new String[0]);
+ InternalSearchUI.getInstance().removeQuery(query1);
+ InternalSearchUI.getInstance().removeQuery(query2);
+ query1= null;
+ query2= null;
+ assertInstanceCount(JavaSearchResult.class, 0);
+ }
+ public void testRemoveAllQueries() throws Exception {
+ SearchTestHelper.runMethodRefQuery("junit.framework.Test", "countTestCases", new String[0]);
+ SearchTestHelper.runMethodRefQuery("junit.framework.TestCase", "countTestCases", new String[0]);
+ InternalSearchUI.getInstance().removeAllQueries();
+ assertInstanceCount(JavaSearchResult.class, 0);
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/SearchLeakTestWrapper.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/SearchLeakTestWrapper.java
new file mode 100644
index 000000000..9c895d5e2
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/SearchLeakTestWrapper.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.leaks;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.jdt.ui.leaktest.LeakTestSetup;
+import org.eclipse.jdt.ui.tests.search.JUnitSourceSetup;
+
+
+/**
+ * This class is a wrapper for {@link SearchLeakTest}
+ * in order to prevent the loading of the Search plug-in when the VM
+ * verifies some JDT UI code.
+ *
+ * @since 3.4
+ */
+//{ObjectTeams: moved here from org.eclipse.jdt.ui.tests.search to please the report generator SH}
+public class SearchLeakTestWrapper extends TestCase {
+
+ SearchLeakTest fTest;
+ private String fName;
+
+ public SearchLeakTestWrapper(String name) {
+ super(name);
+ fName= name;
+ }
+
+ public static Test allTests() {
+ return new LeakTestSetup(new JUnitSourceSetup(new TestSuite(SearchLeakTestWrapper.class)));
+ }
+
+ public static Test suite() {
+ return allTests();
+ }
+
+ protected void setUp() throws Exception {
+ fTest= new SearchLeakTest(fName);
+ fTest.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ fTest.tearDown();
+ fTest= null;
+ }
+
+ public void testRemoveSearchQueries() throws Exception {
+ fTest.testRemoveSearchQueries();
+ }
+
+ public void testRemoveAllQueries() throws Exception {
+ fTest.testRemoveAllQueries();
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/TextViewerUndoManagerLeakTest.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/TextViewerUndoManagerLeakTest.java
new file mode 100644
index 000000000..81fbfaca7
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/TextViewerUndoManagerLeakTest.java
@@ -0,0 +1,276 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.leaks;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.text.undo.DocumentUndoManager;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.IUndoManager;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jface.text.TextViewerUndoManager;
+
+import org.eclipse.jdt.ui.leaktest.LeakTestCase;
+import org.eclipse.jdt.ui.leaktest.LeakTestSetup;
+
+/**
+ * Tests for leaks in TextViewerUndoManager.
+ *
+ * @since 3.2
+ */
+public class TextViewerUndoManagerLeakTest extends LeakTestCase {
+
+ /** The maximum undo level. */
+ private static final int MAX_UNDO_LEVEL= 256;
+
+ /** The shell. */
+ private Shell fShell;
+ /** The text viewer. */
+ private ITextViewer fTextViewer;
+ /** The undo manager. */
+ private IUndoManager fUndoManager;
+
+ public static Test suite() {
+ return new LeakTestSetup(new TestSuite(TextViewerUndoManagerLeakTest.class));
+ }
+
+ /*
+ * @see TestCase#TestCase(String)
+ */
+ public TextViewerUndoManagerLeakTest(final String name) {
+ super(name);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() {
+ fShell= new Shell();
+ fUndoManager= new TextViewerUndoManager(MAX_UNDO_LEVEL);
+ fTextViewer= new TextViewer(fShell, SWT.NONE);
+ fTextViewer.setUndoManager(fUndoManager);
+ fUndoManager.connect(fTextViewer);
+ }
+
+ public void testTextViewerUndoManager() throws Exception{
+ // There is always a document instance around, hence a DocumentUndoManager.
+ // So count instances first.
+ // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=61432
+ int instanceCount= getInstanceCount(DocumentUndoManager.class);
+ internalTestConvertLineDelimiters();
+ internalTestRandomAccess();
+ internalTestRandomAccessAsCompound();
+
+ fUndoManager.disconnect();
+ fUndoManager= null;
+
+ fShell.dispose();
+ fShell= null;
+
+ fTextViewer= null;
+
+ String[] types= {
+ TextViewer.class.getName(),
+ TextViewerUndoManager.class.getName(),
+
+ getSharedUndoManagersInnerClass("TextInputListener").getName(),
+ getSharedUndoManagersInnerClass("DocumentUndoListener").getName(),
+ getSharedUndoManagersInnerClass("KeyAndMouseListener").getName(),
+
+ DocumentUndoManager.class.getName(),
+ getDocumentUndoManagersInnerClass("DocumentListener").getName(),
+ getDocumentUndoManagersInnerClass("HistoryListener").getName(),
+ };
+ int expected[]= new int[] { 0, 0, 0, 0, 0, instanceCount, 0, 0};
+
+ assertInstanceCount(types, expected);
+ }
+
+ private Class getSharedUndoManagersInnerClass(String className) {
+ try {
+ return Class.forName("org.eclipse.jface.text.TextViewerUndoManager$" + className, true, getClass().getClassLoader());
+ } catch (ClassNotFoundException e) {
+ fail();
+ return null;
+ }
+ }
+
+ private Class getDocumentUndoManagersInnerClass(String className) {
+ try {
+ return Class.forName("org.eclipse.text.undo.DocumentUndoManager$" + className, true, getClass().getClassLoader());
+ } catch (ClassNotFoundException e) {
+ fail();
+ return null;
+ }
+ }
+
+
+ /**
+ * Test for line delimiter conversion.
+ */
+ private void internalTestConvertLineDelimiters() {
+ final String original= "a\r\nb\r\n";
+ final IDocument document= new Document(original);
+ fTextViewer.setDocument(document);
+
+ try {
+ document.replace(1, 2, "\n");
+ document.replace(3, 2, "\n");
+ } catch (BadLocationException e) {
+ assertTrue(false);
+ }
+
+ assertTrue(fUndoManager.undoable());
+ fUndoManager.undo();
+ assertTrue(fUndoManager.undoable());
+ fUndoManager.undo();
+
+ final String reverted= document.get();
+
+ assertEquals(original, reverted);
+ }
+
+ /**
+ * Randomly applies document changes.
+ */
+ private void internalTestRandomAccess() {
+ final int RANDOM_STRING_LENGTH= 50;
+ final int RANDOM_REPLACE_COUNT= 100;
+
+ assertTrue(RANDOM_REPLACE_COUNT >= 1);
+ assertTrue(RANDOM_REPLACE_COUNT <= MAX_UNDO_LEVEL);
+
+ String original= createRandomString(RANDOM_STRING_LENGTH);
+ final IDocument document= new Document(original);
+ fTextViewer.setDocument(document);
+
+ doChange(document, RANDOM_REPLACE_COUNT);
+
+ assertTrue(fUndoManager.undoable());
+ while (fUndoManager.undoable())
+ fUndoManager.undo();
+
+ final String reverted= document.get();
+
+ assertEquals(original, reverted);
+ }
+
+ private void doChange(IDocument document, int count) {
+ try {
+ for (int i= 0; i < count; i++) {
+ final Position position= createRandomPositionPoisson(document.getLength());
+ final String string= createRandomStringPoisson();
+ document.replace(position.getOffset(), position.getLength(), string);
+ }
+ } catch (BadLocationException e) {
+ assertTrue(false);
+ }
+ }
+
+ private void internalTestRandomAccessAsCompound() {
+ final int RANDOM_STRING_LENGTH= 50;
+ final int RANDOM_REPLACE_COUNT= 100;
+
+ assertTrue(RANDOM_REPLACE_COUNT >= 1);
+ assertTrue(RANDOM_REPLACE_COUNT <= MAX_UNDO_LEVEL);
+
+ String original= createRandomString(RANDOM_STRING_LENGTH);
+ final IDocument document= new Document(original);
+ fTextViewer.setDocument(document);
+
+ fUndoManager.beginCompoundChange();
+ doChange(document, RANDOM_REPLACE_COUNT);
+ fUndoManager.endCompoundChange();
+
+ assertTrue(fUndoManager.undoable());
+ while (fUndoManager.undoable())
+ fUndoManager.undo();
+ assertTrue(!fUndoManager.undoable());
+
+ final String reverted= document.get();
+
+ assertEquals(original, reverted);
+ }
+
+ private static String createRandomString(int length) {
+ final StringBuffer buffer= new StringBuffer();
+
+ for (int i= 0; i < length; i++)
+ buffer.append(getRandomCharacter());
+
+ return buffer.toString();
+ }
+
+ private static final char getRandomCharacter() {
+// return Math.random() < 0.5
+// ? '\r'
+// : '\n';
+
+ // XXX must include \r, \n, \t
+ return (char) (32 + 95 * Math.random());
+ }
+
+ private static String createRandomStringPoisson() {
+ final int length= getRandomPoissonValue(2);
+ return createRandomString(length);
+ }
+
+ private static Position createRandomPositionPoisson(int documentLength) {
+
+ final float random= (float) Math.random();
+ final int offset= (int) (random * (documentLength + 1));
+
+ int length= getRandomPoissonValue(2);
+ if (offset + length > documentLength)
+ length= documentLength - offset;
+
+ return new Position(offset, length);
+ }
+
+ private static int getRandomPoissonValue(int mean) {
+ final int MAX_VALUE= 10;
+
+ final float random= (float) Math.random();
+ float probability= 0;
+ int i= 0;
+ while (probability < 1 && i < MAX_VALUE) {
+ probability += getPoissonDistribution(mean, i);
+ if (random <= probability)
+ break;
+ i++;
+ }
+ return i;
+ }
+
+ private static float getPoissonDistribution(float lambda, int k) {
+ return (float) (Math.exp(-lambda) * Math.pow(lambda, k) / faculty(k));
+ }
+
+ /**
+ * Returns the faculty of k.
+ * @param k value
+ * @return the faculty of the value
+ */
+ private static final int faculty(int k) {
+ return k == 0
+ ? 1
+ : k * faculty(k - 1);
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/UndoManagerLeakTest.java b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/UndoManagerLeakTest.java
new file mode 100644
index 000000000..293f0cb58
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/tests/leaks/UndoManagerLeakTest.java
@@ -0,0 +1,256 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.leaks;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultUndoManager;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.IUndoManager;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.TextViewer;
+
+import org.eclipse.jdt.ui.leaktest.LeakTestCase;
+import org.eclipse.jdt.ui.leaktest.LeakTestSetup;
+
+/**
+ * Test for leaks in DefaultUndoManager.
+ *
+ * @since 3.1
+ */
+public class UndoManagerLeakTest extends LeakTestCase {
+
+ /** The maximum undo level. */
+ private static final int MAX_UNDO_LEVEL= 256;
+
+ /** The shell. */
+ private Shell fShell;
+ /** The text viewer. */
+ private ITextViewer fTextViewer;
+ /** The undo manager. */
+ private IUndoManager fUndoManager;
+
+ public static Test suite() {
+ return new LeakTestSetup(new TestSuite(UndoManagerLeakTest.class));
+ }
+
+ /*
+ * @see TestCase#TestCase(String)
+ */
+ public UndoManagerLeakTest(final String name) {
+ super(name);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() {
+ fShell= new Shell();
+ fUndoManager= new DefaultUndoManager(MAX_UNDO_LEVEL);
+ fTextViewer= new TextViewer(fShell, SWT.NONE);
+ fTextViewer.setUndoManager(fUndoManager);
+ fUndoManager.connect(fTextViewer);
+ }
+
+ public void testUndoManagerLeak() {
+ internalTestConvertLineDelimiters();
+ internalTestRandomAccess();
+ internalTestRandomAccessAsCompound();
+
+ fUndoManager.disconnect();
+ fUndoManager= null;
+
+ fShell.dispose();
+ fShell= null;
+
+ fTextViewer= null;
+
+
+ String[] types= {
+ TextViewer.class.getName(),
+ DefaultUndoManager.class.getName(),
+
+ getDefaultUndoManagersInnerClass("HistoryListener").getName(),
+ getDefaultUndoManagersInnerClass("TextCommand").getName(),
+ getDefaultUndoManagersInnerClass("CompoundTextCommand").getName(),
+ };
+ int expected[]= new int[] { 0, 0, 0, 0, 0};
+
+ assertInstanceCount(types, expected);
+ }
+
+ private Class getDefaultUndoManagersInnerClass(String className) {
+ try {
+ return Class.forName("org.eclipse.jface.text.DefaultUndoManager$" + className, true, getClass().getClassLoader());
+ } catch (ClassNotFoundException e) {
+ fail();
+ return null;
+ }
+ }
+
+ /**
+ * Test for line delimiter conversion.
+ */
+ private void internalTestConvertLineDelimiters() {
+ final String original= "a\r\nb\r\n";
+ final IDocument document= new Document(original);
+ fTextViewer.setDocument(document);
+
+ try {
+ document.replace(1, 2, "\n");
+ document.replace(3, 2, "\n");
+ } catch (BadLocationException e) {
+ assertTrue(false);
+ }
+
+ assertTrue(fUndoManager.undoable());
+ fUndoManager.undo();
+ assertTrue(fUndoManager.undoable());
+ fUndoManager.undo();
+
+ final String reverted= document.get();
+
+ assertEquals(original, reverted);
+ }
+
+ /**
+ * Randomly applies document changes.
+ */
+ private void internalTestRandomAccess() {
+ final int RANDOM_STRING_LENGTH= 50;
+ final int RANDOM_REPLACE_COUNT= 100;
+
+ assertTrue(RANDOM_REPLACE_COUNT >= 1);
+ assertTrue(RANDOM_REPLACE_COUNT <= MAX_UNDO_LEVEL);
+
+ String original= createRandomString(RANDOM_STRING_LENGTH);
+ final IDocument document= new Document(original);
+ fTextViewer.setDocument(document);
+
+ doChange(document, RANDOM_REPLACE_COUNT);
+
+ assertTrue(fUndoManager.undoable());
+ while (fUndoManager.undoable())
+ fUndoManager.undo();
+
+ final String reverted= document.get();
+
+ assertEquals(original, reverted);
+ }
+
+ private void doChange(IDocument document, int count) {
+ try {
+ for (int i= 0; i < count; i++) {
+ final Position position= createRandomPositionPoisson(document.getLength());
+ final String string= createRandomStringPoisson(4);
+ document.replace(position.getOffset(), position.getLength(), string);
+ }
+ } catch (BadLocationException e) {
+ assertTrue(false);
+ }
+ }
+
+ private void internalTestRandomAccessAsCompound() {
+ final int RANDOM_STRING_LENGTH= 50;
+ final int RANDOM_REPLACE_COUNT= 100;
+
+ assertTrue(RANDOM_REPLACE_COUNT >= 1);
+ assertTrue(RANDOM_REPLACE_COUNT <= MAX_UNDO_LEVEL);
+
+ String original= createRandomString(RANDOM_STRING_LENGTH);
+ final IDocument document= new Document(original);
+ fTextViewer.setDocument(document);
+
+ fUndoManager.beginCompoundChange();
+ doChange(document, RANDOM_REPLACE_COUNT);
+ fUndoManager.endCompoundChange();
+
+ assertTrue(fUndoManager.undoable());
+ while (fUndoManager.undoable())
+ fUndoManager.undo();
+ assertTrue(!fUndoManager.undoable());
+
+ final String reverted= document.get();
+
+ assertEquals(original, reverted);
+ }
+
+ private static String createRandomString(int length) {
+ final StringBuffer buffer= new StringBuffer();
+
+ for (int i= 0; i < length; i++)
+ buffer.append(getRandomCharacter());
+
+ return buffer.toString();
+ }
+
+ private static final char getRandomCharacter() {
+// return Math.random() < 0.5
+// ? '\r'
+// : '\n';
+
+ // XXX must include \r, \n, \t
+ return (char) (32 + 95 * Math.random());
+ }
+
+ private static String createRandomStringPoisson(int mean) {
+ final int length= getRandomPoissonValue(2);
+ return createRandomString(length);
+ }
+
+ private static Position createRandomPositionPoisson(int documentLength) {
+
+ final float random= (float) Math.random();
+ final int offset= (int) (random * (documentLength + 1));
+
+ int length= getRandomPoissonValue(2);
+ if (offset + length > documentLength)
+ length= documentLength - offset;
+
+ return new Position(offset, length);
+ }
+
+ private static int getRandomPoissonValue(int mean) {
+ final int MAX_VALUE= 10;
+
+ final float random= (float) Math.random();
+ float probability= 0;
+ int i= 0;
+ while (probability < 1 && i < MAX_VALUE) {
+ probability += getPoissonDistribution(mean, i);
+ if (random <= probability)
+ break;
+ i++;
+ }
+ return i;
+ }
+
+ private static float getPoissonDistribution(float lambda, int k) {
+ return (float) (Math.exp(-lambda) * Math.pow(lambda, k) / faculty(k));
+ }
+
+ /**
+ * Returns the faculty of k.
+ */
+ private static final int faculty(int k) {
+ return k == 0
+ ? 1
+ : k * faculty(k - 1);
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/FileTool.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/FileTool.java
new file mode 100644
index 000000000..a452f84db
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/FileTool.java
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.ui.tests.performance;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+
+
+public class FileTool {
+
+ /**
+ * A buffer.
+ */
+ private static byte[] fgBuffer = new byte[8192];
+
+ /**
+ * Unzips the given zip file to the given destination directory
+ * extracting only those entries the pass through the given
+ * filter.
+ *
+ * @param zipFile the zip file to unzip
+ * @param dstDir the destination directory
+ * @throws IOException
+ */
+ public static void unzip(ZipFile zipFile, File dstDir) throws IOException {
+ unzip(zipFile, dstDir, dstDir, 0);
+ }
+
+ private static void unzip(ZipFile zipFile, File rootDstDir, File dstDir, int depth) throws IOException {
+
+ Enumeration entries = zipFile.entries();
+
+ try {
+ while(entries.hasMoreElements()){
+ ZipEntry entry = (ZipEntry)entries.nextElement();
+ if(entry.isDirectory()){
+ continue;
+ }
+ String entryName = entry.getName();
+ File file = new File(dstDir, changeSeparator(entryName, '/', File.separatorChar));
+ file.getParentFile().mkdirs();
+ InputStream src = null;
+ OutputStream dst = null;
+ try {
+ src = zipFile.getInputStream(entry);
+ dst = new FileOutputStream(file);
+ transferData(src, dst);
+ } finally {
+ if(dst != null){
+ try {
+ dst.close();
+ } catch(IOException e){
+ }
+ }
+ if(src != null){
+ try {
+ src.close();
+ } catch(IOException e){
+ }
+ }
+ }
+ }
+ } finally {
+ try {
+ zipFile.close();
+ } catch(IOException e){
+ }
+ }
+ }
+ /**
+ * Returns the given file path with its separator
+ * character changed from the given old separator to the
+ * given new separator.
+ *
+ * @param path a file path
+ * @param oldSeparator a path separator character
+ * @param newSeparator a path separator character
+ * @return the file path with its separator character
+ * changed from the given old separator to the given new
+ * separator
+ */
+ public static String changeSeparator(String path, char oldSeparator, char newSeparator){
+ return path.replace(oldSeparator, newSeparator);
+ }
+
+ /**
+ * Copies all bytes in the given source file to
+ * the given destination file.
+ *
+ * @param source the given source file
+ * @param destination the given destination file
+ * @throws IOException
+ */
+ public static void transferData(File source, File destination) throws IOException {
+ destination.getParentFile().mkdirs();
+ InputStream is = null;
+ OutputStream os = null;
+ try {
+ is = new FileInputStream(source);
+ os = new FileOutputStream(destination);
+ transferData(is, os);
+ } finally {
+ if(os != null){
+ try {
+ os.close();
+ } catch(IOException e){
+ }
+ }
+ if(is != null){
+ try {
+ is.close();
+ } catch(IOException e){
+ }
+ }
+ }
+ }
+
+ /**
+ * Copies all bytes in the given source stream to
+ * the given destination stream. Neither streams
+ * are closed.
+ *
+ * @param source the given source stream
+ * @param destination the given destination stream
+ * @throws IOException
+ */
+ public static void transferData(InputStream source, OutputStream destination) throws IOException {
+ int bytesRead = 0;
+ while(bytesRead != -1){
+ bytesRead = source.read(fgBuffer, 0, fgBuffer.length);
+ if(bytesRead != -1){
+ destination.write(fgBuffer, 0, bytesRead);
+ }
+ }
+ }
+
+ /**
+ * Copies the given source file to the given destination file.
+ *
+ * @param src the given source file
+ * @param dst the given destination file
+ * @throws IOException
+ */
+ public static void copy(File src, File dst) throws IOException {
+ if(src.isDirectory()){
+ String[] srcChildren = src.list();
+ for(int i = 0; i < srcChildren.length; ++i){
+ File srcChild= new File(src, srcChildren[i]);
+ File dstChild= new File(dst, srcChildren[i]);
+ copy(srcChild, dstChild);
+ }
+ } else
+ transferData(src, dst);
+ }
+
+ public static File getFileInPlugin(Plugin plugin, IPath path) {
+ try {
+ URL installURL= plugin.getBundle().getEntry(path.toString());
+ URL localURL= Platform.asLocalURL(installURL);
+ return new File(localURL.getFile());
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ public static StringBuffer read(String fileName) throws IOException {
+ return read(new FileReader(fileName));
+ }
+
+ public static StringBuffer read(Reader reader) throws IOException {
+ StringBuffer s= new StringBuffer();
+ try {
+ char[] buffer= new char[8196];
+ int chars= reader.read(buffer);
+ while (chars != -1) {
+ s.append(buffer, 0, chars);
+ chars= reader.read(buffer);
+ }
+ } finally {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ }
+ }
+ return s;
+ }
+
+ public static void write(String fileName, StringBuffer content) throws IOException {
+ Writer writer= new FileWriter(fileName);
+ try {
+ writer.write(content.toString());
+ } finally {
+ try {
+ writer.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/JdtPerformanceTestCase.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/JdtPerformanceTestCase.java
new file mode 100644
index 000000000..d1bbf2c0b
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/JdtPerformanceTestCase.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.ui.tests.performance;
+
+import org.eclipse.jdt.testplugin.JavaProjectHelper;
+import org.eclipse.test.performance.Dimension;
+import org.eclipse.test.performance.PerformanceTestCase;
+
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.jobs.IJobManager;
+import org.eclipse.core.runtime.jobs.Job;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+
+public class JdtPerformanceTestCase extends PerformanceTestCase {
+
+ public JdtPerformanceTestCase() {
+ super();
+ }
+
+ public JdtPerformanceTestCase(String name) {
+ super(name);
+ }
+
+ protected void joinBackgroudActivities() throws CoreException {
+ // Join Building
+ boolean interrupted= true;
+ while (interrupted) {
+ try {
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+ interrupted= false;
+ } catch (InterruptedException e) {
+ interrupted= true;
+ }
+ }
+ // Join indexing
+ JavaProjectHelper.performDummySearch();
+ // Join jobs. Maximal wait 1 minute before all jobs have completed
+ if(!joinJobs(0, 1 * 60 * 1000, 500)) {
+ JavaPlugin.logErrorMessage("Performance test " + getName() + " started with running background activity");
+ }
+ }
+
+ private static boolean joinJobs(long minTime, long maxTime, long intervalTime) {
+ long startTime= System.currentTimeMillis() + minTime;
+ runEventQueue();
+ while (System.currentTimeMillis() < startTime)
+ runEventQueue(intervalTime);
+
+ long endTime= maxTime > 0 && maxTime < Long.MAX_VALUE ? System.currentTimeMillis() + maxTime : Long.MAX_VALUE;
+ boolean calm= allJobsQuiet();
+ while (!calm && System.currentTimeMillis() < endTime) {
+ runEventQueue(intervalTime);
+ calm= allJobsQuiet();
+ }
+ return calm;
+ }
+
+ private static void sleep(int intervalTime) {
+ try {
+ Thread.sleep(intervalTime);
+ } catch (InterruptedException e) {
+ }
+ }
+
+ private static boolean allJobsQuiet() {
+ IJobManager jobManager= Job.getJobManager();
+ Job[] jobs= jobManager.find(null);
+ for (int i= 0; i < jobs.length; i++) {
+ Job job= jobs[i];
+ int state= job.getState();
+ if (state == Job.RUNNING || state == Job.WAITING)
+ return false;
+ }
+ return true;
+ }
+
+ private static void runEventQueue() {
+ IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null)
+ runEventQueue(window.getShell());
+ }
+
+ private static void runEventQueue(Shell shell) {
+ while (shell.getDisplay().readAndDispatch()) {
+ // do nothing
+ }
+ }
+
+ private static void runEventQueue(long minTime) {
+ long nextCheck= System.currentTimeMillis() + minTime;
+ while (System.currentTimeMillis() < nextCheck) {
+ runEventQueue();
+ sleep(1);
+ }
+ }
+
+ protected void finishMeasurements() {
+ stopMeasuring();
+ commitMeasurements();
+ assertPerformanceInRelativeBand(Dimension.ELAPSED_PROCESS, -100, +10);
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/PerformanceTestSuite.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/PerformanceTestSuite.java
new file mode 100644
index 000000000..8c0f81f72
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/PerformanceTestSuite.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.ui.tests.performance;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.jdt.ui.tests.performance.views.TypeHierarchyPerfTest;
+
+public class PerformanceTestSuite {
+ public static Test suite() {
+ TestSuite suite= new TestSuite("jdt.ui performance tests");
+ suite.addTest(TypeHierarchyPerfTest.suite());
+ return suite;
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/SWTTestProject.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/SWTTestProject.java
new file mode 100644
index 000000000..1cad568c2
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/SWTTestProject.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.performance;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
+
+import junit.framework.Assert;
+
+import org.eclipse.jdt.testplugin.JavaProjectHelper;
+import org.eclipse.jdt.testplugin.JavaTestPlugin;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+
+
+public class SWTTestProject {
+
+ public static final String PROJECT= "org.eclipse.swt";
+ private static final String PROJECT_ZIP= "/testresources/org.eclipse.swt-R3_0.zip";
+
+ private IJavaProject fProject;
+
+ public SWTTestProject() throws Exception {
+ setUpProject();
+ }
+
+ public IJavaProject getProject() {
+ return fProject;
+ }
+
+ public void delete() throws Exception {
+ if (fProject != null && fProject.exists()) {
+ JavaProjectHelper.delete(fProject);
+ }
+ }
+
+ private void setUpProject() throws IOException, ZipException, CoreException {
+ String workspacePath= ResourcesPlugin.getWorkspace().getRoot().getLocation().toString() + "/";
+ FileTool.unzip(new ZipFile(FileTool.getFileInPlugin(JavaTestPlugin.getDefault(), new Path(PROJECT_ZIP))), new File(workspacePath));
+ File oldFile= new File(workspacePath + PROJECT + "/.classpath_win32");
+ File newFile= new File(workspacePath + PROJECT + "/.classpath");
+ Assert.assertTrue(oldFile.renameTo(newFile));
+
+ IProject project= createExistingProject(PROJECT);
+ fProject= JavaCore.create(project);
+
+ //some classes in the archive are not 1.4 compliant, e.g. GridData uses 'enum' as identifier
+ Map options= fProject.getOptions(false);
+ JavaCore.setComplianceOptions(JavaCore.VERSION_1_3, options);
+ fProject.setOptions(options);
+
+ Assert.assertTrue(fProject.exists());
+ }
+
+ private IProject createExistingProject(String projectName) throws CoreException {
+ IWorkspace workspace= ResourcesPlugin.getWorkspace();
+ IProject project= workspace.getRoot().getProject(projectName);
+ IProjectDescription description= workspace.newProjectDescription(projectName);
+ description.setLocation(null);
+
+ project.create(description, null);
+ project.open(null);
+ return project;
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/Accessor.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/Accessor.java
new file mode 100644
index 000000000..ea4254c37
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/Accessor.java
@@ -0,0 +1,333 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.performance.views;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.eclipse.core.runtime.Assert;
+
+
+/**
+ * Helper class for accessing classes and members which cannot be accessed using standard Java
+ * access control like private or package visible elements.
+ * <p>
+ * <strong>Note:</strong> Copied from org.eclipse.text.tests.
+ * </p>
+ *
+ * @since 3.5
+ */
+class Accessor {
+
+ /** The class to access. */
+ private Class fClass;
+ /** The instance to access. */
+ private Object fInstance;
+
+ /**
+ * Creates an accessor for the given <code>instance</code> and
+ * <code>class</code>. Only non-inherited members that particular
+ * <code>class</code> can be accessed.
+ *
+ * @param instance the instance
+ * @param clazz the class
+ */
+ public Accessor(Object instance, Class clazz) {
+ org.eclipse.core.runtime.Assert.isNotNull(instance);
+ Assert.isNotNull(clazz);
+ fInstance= instance;
+ fClass= clazz;
+ }
+
+ /**
+ * Creates an accessor for the given <code>instance</code> and
+ * <code>class</code>. Only non-inherited members that particular
+ * <code>class</code> can be accessed.
+ *
+ * @param instance the instance
+ * @param className the name of the class
+ * @param classLoader the class loader to use i.e. <code>getClass().getClassLoader()</code>
+ */
+ public Accessor(Object instance, String className, ClassLoader classLoader) {
+ Assert.isNotNull(instance);
+ Assert.isNotNull(className);
+ Assert.isNotNull(classLoader);
+ fInstance= instance;
+ try {
+ fClass= Class.forName(className, true, classLoader);
+ } catch (ClassNotFoundException e) {
+ fail();
+ } catch (ExceptionInInitializerError e) {
+ fail();
+ }
+ }
+
+ /**
+ * Creates an accessor for the given class.
+ * <p>
+ * In order to get the type information from the given
+ * arguments they must all be instanceof Object. Use
+ * {@link #Accessor(String, ClassLoader, Class[], Object[])} if this
+ * is not the case.</p>
+ *
+ * @param className the name of the class
+ * @param classLoader the class loader to use i.e. <code>getClass().getClassLoader()</code>
+ * @param constructorArgs the constructor arguments which must all be instance of Object
+ */
+ public Accessor(String className, ClassLoader classLoader, Object[] constructorArgs) {
+ this(className, classLoader, getTypes(constructorArgs), constructorArgs);
+ }
+
+ /**
+ * Creates an accessor for the given class.
+ *
+ * @param className the name of the class
+ * @param classLoader the class loader to use i.e. <code>getClass().getClassLoader()</code>
+ * @param constructorTypes the types of the constructor arguments
+ * @param constructorArgs the constructor arguments
+ */
+ public Accessor(String className, ClassLoader classLoader, Class[] constructorTypes, Object[] constructorArgs) {
+ try {
+ fClass= Class.forName(className, true, classLoader);
+ } catch (ClassNotFoundException e) {
+ fail();
+ } catch (ExceptionInInitializerError e) {
+ fail();
+ }
+ Constructor constructor= null;
+ try {
+ constructor= fClass.getDeclaredConstructor(constructorTypes);
+ } catch (SecurityException e2) {
+ fail();
+ } catch (NoSuchMethodException e2) {
+ fail();
+ }
+ Assert.isNotNull(constructor);
+ constructor.setAccessible(true);
+ try {
+ fInstance= constructor.newInstance(constructorArgs);
+ } catch (IllegalArgumentException e) {
+ fail();
+ } catch (InvocationTargetException e) {
+ fail();
+ } catch (InstantiationException e) {
+ fail();
+ } catch (IllegalAccessException e) {
+ fail();
+ }
+ }
+
+ /**
+ * Creates an accessor for the given class.
+ * <p>
+ * This constructor is used to access static stuff.
+ * </p>
+ *
+ * @param className the name of the class
+ * @param classLoader the class loader to use i.e. <code>getClass().getClassLoader()</code>
+ */
+ public Accessor(String className, ClassLoader classLoader) {
+ try {
+ fClass= Class.forName(className, true, classLoader);
+ } catch (ClassNotFoundException e) {
+ fail();
+ } catch (ExceptionInInitializerError e) {
+ fail();
+ }
+ }
+
+ /**
+ * Invokes the method with the given method name and arguments.
+ * <p>
+ * In order to get the type information from the given
+ * arguments all those arguments must be instance of Object. Use
+ * {@link #invoke(String, Class[], Object[])} if this
+ * is not the case.</p>
+ *
+ * @param methodName the method name
+ * @param arguments the method arguments which must all be instance of Object
+ * @return the method return value
+ */
+ public Object invoke(String methodName, Object[] arguments) {
+ return invoke(methodName, getTypes(arguments), arguments);
+ }
+
+ /**
+ * Invokes the method with the given method name and arguments.
+ *
+ * @param methodName the method name
+ * @param types the argument types
+ * @param arguments the method arguments
+ * @return the method return value
+ */
+ public Object invoke(String methodName, Class[] types, Object[] arguments) {
+ Method method= null;
+ try {
+ method= fClass.getDeclaredMethod(methodName, types);
+ } catch (SecurityException e) {
+ fail();
+ } catch (NoSuchMethodException ex) {
+ fail();
+ }
+ Assert.isNotNull(method);
+ method.setAccessible(true);
+ try {
+ return method.invoke(fInstance, arguments);
+ } catch (IllegalArgumentException e) {
+ fail();
+ } catch (InvocationTargetException e) {
+ fail();
+ } catch (IllegalAccessException e) {
+ fail();
+ }
+ return null;
+ }
+
+ /**
+ * Assigns the given value to the field with the given name.
+ *
+ * @param fieldName the field name
+ * @param value the value to assign to the field
+ */
+ public void set(String fieldName, Object value) {
+ Field field= getField(fieldName);
+ try {
+ field.set(fInstance, value);
+ } catch (IllegalArgumentException e) {
+ fail();
+ } catch (IllegalAccessException e) {
+ fail();
+ }
+ }
+
+ /**
+ * Assigns the given value to the field with the given name.
+ *
+ * @param fieldName the field name
+ * @param value the value to assign to the field
+ */
+ public void set(String fieldName, boolean value) {
+ Field field= getField(fieldName);
+ try {
+ field.setBoolean(fInstance, value);
+ } catch (IllegalArgumentException e) {
+ fail();
+ } catch (IllegalAccessException e) {
+ fail();
+ }
+ }
+
+ /**
+ * Assigns the given value to the field with the given name.
+ *
+ * @param fieldName the field name
+ * @param value the value to assign to the field
+ */
+ public void set(String fieldName, int value) {
+ Field field= getField(fieldName);
+ try {
+ field.setInt(fInstance, value);
+ } catch (IllegalArgumentException e) {
+ fail();
+ } catch (IllegalAccessException e) {
+ fail();
+ }
+ }
+
+ /**
+ * Returns the value of the field with the given name.
+ *
+ * @param fieldName the field name
+ * @return the value of the field
+ */
+ public Object get(String fieldName) {
+ Field field= getField(fieldName);
+ try {
+ return field.get(fInstance);
+ } catch (IllegalArgumentException e) {
+ fail();
+ } catch (IllegalAccessException e) {
+ fail();
+ }
+ // Unreachable code
+ return null;
+ }
+
+ /**
+ * Returns the value of the field with the given name.
+ *
+ * @param fieldName the field name
+ * @return the value of the field
+ */
+ public boolean getBoolean(String fieldName) {
+ Field field= getField(fieldName);
+ try {
+ return field.getBoolean(fInstance);
+ } catch (IllegalArgumentException e) {
+ fail();
+ } catch (IllegalAccessException e) {
+ fail();
+ }
+ // Unreachable code
+ return false;
+ }
+
+ /**
+ * Returns the value of the field with the given name.
+ *
+ * @param fieldName the field name
+ * @return the value of the field
+ */
+ public int getInt(String fieldName) {
+ Field field= getField(fieldName);
+ try {
+ return field.getInt(fInstance);
+ } catch (IllegalArgumentException e) {
+ fail();
+ } catch (IllegalAccessException e) {
+ fail();
+ }
+ // Unreachable code
+ return 0;
+ }
+
+ private Field getField(String fieldName) {
+ Field field= null;
+ try {
+ field= fClass.getDeclaredField(fieldName);
+ } catch (SecurityException e) {
+ fail();
+ } catch (NoSuchFieldException e) {
+ fail();
+ }
+ field.setAccessible(true);
+ return field;
+ }
+
+ private static Class[] getTypes(Object[] objects) {
+ if (objects == null)
+ return null;
+
+ int length= objects.length;
+ Class[] classes= new Class[length];
+ for (int i= 0; i < length; i++) {
+ Assert.isNotNull(objects[i]);
+ classes[i]= objects[i].getClass();
+ }
+ return classes;
+ }
+
+ private void fail() {
+ Assert.isTrue(false);
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java
new file mode 100644
index 000000000..bcc7d64ac
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java
@@ -0,0 +1,479 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Alex Blewitt - https://bugs.eclipse.org/bugs/show_bug.cgi?id=168954
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.performance.views;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.jdt.testplugin.JavaProjectHelper;
+import org.eclipse.jdt.testplugin.JavaTestPlugin;
+import org.eclipse.test.performance.Dimension;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.ltk.core.refactoring.CheckConditionsOperation;
+import org.eclipse.ltk.core.refactoring.PerformRefactoringOperation;
+import org.eclipse.ltk.core.refactoring.RefactoringCore;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaModelException;
+
+import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
+import org.eclipse.jdt.internal.corext.fix.CleanUpPreferenceUtil;
+import org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring;
+
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jdt.ui.cleanup.CleanUpOptions;
+import org.eclipse.jdt.ui.cleanup.CleanUpRequirements;
+import org.eclipse.jdt.ui.cleanup.ICleanUp;
+import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase;
+
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+import org.eclipse.jdt.internal.ui.fix.AbstractCleanUp;
+import org.eclipse.jdt.internal.ui.fix.CodeFormatCleanUp;
+import org.eclipse.jdt.internal.ui.fix.CodeStyleCleanUp;
+import org.eclipse.jdt.internal.ui.fix.ControlStatementsCleanUp;
+import org.eclipse.jdt.internal.ui.fix.ConvertLoopCleanUp;
+import org.eclipse.jdt.internal.ui.fix.ExpressionsCleanUp;
+import org.eclipse.jdt.internal.ui.fix.ImportsCleanUp;
+import org.eclipse.jdt.internal.ui.fix.Java50CleanUp;
+import org.eclipse.jdt.internal.ui.fix.SortMembersCleanUp;
+import org.eclipse.jdt.internal.ui.fix.StringCleanUp;
+import org.eclipse.jdt.internal.ui.fix.UnnecessaryCodeCleanUp;
+import org.eclipse.jdt.internal.ui.fix.UnusedCodeCleanUp;
+import org.eclipse.jdt.internal.ui.fix.VariableDeclarationCleanUp;
+import org.eclipse.jdt.internal.ui.preferences.cleanup.CleanUpProfileVersioner;
+import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager;
+import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileStore;
+
+public class CleanUpPerfTest extends JdtPerformanceTestCase {
+
+ private static class MyTestSetup extends TestSetup {
+ public static final String SRC_CONTAINER= "src";
+
+ public static IJavaProject fJProject1;
+
+ public MyTestSetup(Test test) {
+ super(test);
+ }
+
+ protected void setUp() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ assertTrue("rt not found", JavaProjectHelper.addRTJar(fJProject1) != null);
+ File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
+ JavaProjectHelper.addSourceContainerWithImport(fJProject1, SRC_CONTAINER, junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
+ }
+
+ protected void tearDown() throws Exception {
+ if (fJProject1 != null && fJProject1.exists())
+ JavaProjectHelper.delete(fJProject1);
+ }
+ }
+
+ public static Test suite() {
+ return new MyTestSetup(new TestSuite(CleanUpPerfTest.class));
+ }
+
+ public static Test setUpTest(Test someTest) {
+ return new MyTestSetup(someTest);
+ }
+
+ private void addAllCUs(CleanUpRefactoring cleanUp, IJavaElement[] children) throws JavaModelException {
+ for (int i= 0; i < children.length; i++) {
+ IJavaElement element= children[i];
+ if (element instanceof ICompilationUnit) {
+ cleanUp.addCompilationUnit((ICompilationUnit)element);
+ } else if (element instanceof IPackageFragmentRoot) {
+ IPackageFragmentRoot root= (IPackageFragmentRoot)element;
+ addAllCUs(cleanUp, root.getChildren());
+ } else if (element instanceof IPackageFragment) {
+ IPackageFragment pack= (IPackageFragment)element;
+ addAllCUs(cleanUp, pack.getChildren());
+ }
+ }
+ }
+
+ private static Map getNullSettings() {
+ Map result= new HashMap();
+
+ Collection keys= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_CLEAN_UP_OPTIONS).getKeys();
+ for (Iterator iterator= keys.iterator(); iterator.hasNext();) {
+ String key= (String)iterator.next();
+ result.put(key, CleanUpOptions.FALSE);
+ }
+
+ return result;
+ }
+
+ private static void storeSettings(Map node) throws CoreException {
+ ProfileManager.CustomProfile profile= new ProfileManager.CustomProfile("testProfile", node, CleanUpProfileVersioner.CURRENT_VERSION, CleanUpProfileVersioner.PROFILE_KIND);
+ new InstanceScope().getNode(JavaUI.ID_PLUGIN).put(CleanUpConstants.CLEANUP_PROFILE, profile.getID());
+
+ List profiles= CleanUpPreferenceUtil.getBuiltInProfiles();
+ profiles.add(profile);
+
+ CleanUpProfileVersioner versioner= new CleanUpProfileVersioner();
+ ProfileStore profileStore= new ProfileStore(CleanUpConstants.CLEANUP_PROFILES, versioner);
+ profileStore.writeProfiles(profiles, new InstanceScope());
+ }
+
+ public void testNullCleanUp() throws Exception {
+ CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring();
+ addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren());
+ cleanUpRefactoring.addCleanUp(new AbstractCleanUp() {
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.fix.AbstractCleanUp#getRequirements()
+ */
+ public CleanUpRequirements getRequirements() {
+ return new CleanUpRequirements(true, false, false, null);
+ }
+ });
+
+ doCleanUp(cleanUpRefactoring);
+ }
+
+ public void testAllCleanUps() throws Exception {
+ CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring();
+ addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren());
+
+ Map node= getNullSettings();
+
+ node.put(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_ALWAYS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_FIELD, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_METHOD, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS, CleanUpOptions.TRUE);
+
+ node.put(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS, CleanUpOptions.TRUE);
+
+ node.put(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS, CleanUpOptions.TRUE);
+
+ node.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS_DEPRECATED, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE, CleanUpOptions.TRUE);
+
+ node.put(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT, CleanUpOptions.TRUE);
+
+ node.put(CleanUpConstants.ADD_MISSING_NLS_TAGS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.REMOVE_UNNECESSARY_CASTS, CleanUpOptions.TRUE);
+
+ node.put(CleanUpConstants.REMOVE_UNUSED_CODE_IMPORTS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES, CleanUpOptions.TRUE);
+
+ node.put(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PARAMETERS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PRIVATE_FIELDS, CleanUpOptions.TRUE);
+
+ node.put(CleanUpConstants.FORMAT_SOURCE_CODE, CleanUpOptions.TRUE);
+
+ node.put(CleanUpConstants.ORGANIZE_IMPORTS, CleanUpOptions.TRUE);
+
+ storeSettings(node);
+
+ ICleanUp[] cleanUps= JavaPlugin.getDefault().getCleanUpRegistry().createCleanUps();
+ for (int i= 0; i < cleanUps.length; i++) {
+ cleanUpRefactoring.addCleanUp(cleanUps[i]);
+ }
+
+ //See https://bugs.eclipse.org/bugs/show_bug.cgi?id=135219
+ // tagAsSummary("Code Clean Up - 25 clean-ups", Dimension.ELAPSED_PROCESS);
+
+ doCleanUp(cleanUpRefactoring);
+ }
+
+ public void testCodeStyleCleanUp() throws Exception {
+ tagAsSummary("Clean Up - Code Style", Dimension.ELAPSED_PROCESS);
+
+ CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring();
+ addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren());
+
+ Map node= getNullSettings();
+
+ node.put(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_ALWAYS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_FIELD, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_METHOD, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS, CleanUpOptions.TRUE);
+
+ storeSettings(node);
+
+ cleanUpRefactoring.addCleanUp(new CodeStyleCleanUp());
+
+ doCleanUp(cleanUpRefactoring);
+ }
+
+ public void testControlStatementsCleanUp() throws Exception {
+ CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring();
+ addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren());
+
+ Map node= getNullSettings();
+
+ node.put(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS, CleanUpOptions.TRUE);
+
+ storeSettings(node);
+
+ cleanUpRefactoring.addCleanUp(new ControlStatementsCleanUp());
+ cleanUpRefactoring.addCleanUp(new ConvertLoopCleanUp());
+
+ doCleanUp(cleanUpRefactoring);
+ }
+
+ public void testConvertLoopCleanUp() throws Exception {
+ CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring();
+ addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren());
+
+ Map node= getNullSettings();
+
+ node.put(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED, CleanUpOptions.TRUE);
+
+ storeSettings(node);
+
+ cleanUpRefactoring.addCleanUp(new ControlStatementsCleanUp());
+ cleanUpRefactoring.addCleanUp(new ConvertLoopCleanUp());
+
+ doCleanUp(cleanUpRefactoring);
+ }
+
+ public void testExpressionsCleanUp() throws Exception {
+ CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring();
+ addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren());
+
+ Map node= getNullSettings();
+
+ node.put(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS, CleanUpOptions.TRUE);
+
+ storeSettings(node);
+
+ cleanUpRefactoring.addCleanUp(new ExpressionsCleanUp());
+
+ doCleanUp(cleanUpRefactoring);
+ }
+
+ public void testJava50CleanUp() throws Exception {
+ CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring();
+ addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren());
+
+ Map node= getNullSettings();
+
+ node.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS_DEPRECATED, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE, CleanUpOptions.TRUE);
+
+ storeSettings(node);
+
+ cleanUpRefactoring.addCleanUp(new Java50CleanUp());
+
+ doCleanUp(cleanUpRefactoring);
+ }
+
+ public void testStringCleanUp() throws Exception {
+ CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring();
+ addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren());
+
+ Map node= getNullSettings();
+
+ node.put(CleanUpConstants.ADD_MISSING_NLS_TAGS, CleanUpOptions.TRUE);
+
+ storeSettings(node);
+
+ cleanUpRefactoring.addCleanUp(new StringCleanUp());
+
+ doCleanUp(cleanUpRefactoring);
+ }
+
+ public void testSortMembersCleanUp() throws Exception {
+ CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring();
+ addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren());
+
+ Map node= getNullSettings();
+
+ node.put(CleanUpConstants.SORT_MEMBERS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.SORT_MEMBERS_ALL, CleanUpOptions.TRUE);
+
+ storeSettings(node);
+
+ cleanUpRefactoring.addCleanUp(new SortMembersCleanUp());
+
+ doCleanUp(cleanUpRefactoring);
+ }
+
+ public void testUnnecessaryCodeCleanUp() throws Exception {
+ CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring();
+ addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren());
+
+ Map node= getNullSettings();
+ node.put(CleanUpConstants.REMOVE_UNNECESSARY_CASTS, CleanUpOptions.TRUE);
+ storeSettings(node);
+
+ cleanUpRefactoring.addCleanUp(new UnnecessaryCodeCleanUp());
+
+ doCleanUp(cleanUpRefactoring);
+ }
+
+ public void testUnusedCodeCleanUp() throws Exception {
+ CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring();
+ addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren());
+
+ Map node= getNullSettings();
+
+ node.put(CleanUpConstants.REMOVE_UNUSED_CODE_IMPORTS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES, CleanUpOptions.TRUE);
+
+ storeSettings(node);
+
+ cleanUpRefactoring.addCleanUp(new UnusedCodeCleanUp());
+
+ doCleanUp(cleanUpRefactoring);
+ }
+
+ public void testVariableDeclarationCleanUp() throws Exception {
+ CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring();
+ addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren());
+
+ Map node= getNullSettings();
+
+ node.put(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PARAMETERS, CleanUpOptions.TRUE);
+ node.put(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PRIVATE_FIELDS, CleanUpOptions.TRUE);
+
+ storeSettings(node);
+
+ cleanUpRefactoring.addCleanUp(new VariableDeclarationCleanUp());
+
+ doCleanUp(cleanUpRefactoring);
+ }
+
+ public void testCodeFormatCleanUp() throws Exception {
+ CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring();
+ addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren());
+
+ Map node= getNullSettings();
+
+ node.put(CleanUpConstants.FORMAT_SOURCE_CODE, CleanUpOptions.TRUE);
+
+ storeSettings(node);
+
+ cleanUpRefactoring.addCleanUp(new CodeFormatCleanUp());
+
+ doCleanUp(cleanUpRefactoring);
+ }
+
+ public void testOrganizeImports() throws Exception {
+ CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring();
+ addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren());
+
+ Map node= getNullSettings();
+
+ node.put(CleanUpConstants.ORGANIZE_IMPORTS, CleanUpOptions.TRUE);
+
+ storeSettings(node);
+
+ cleanUpRefactoring.addCleanUp(new ImportsCleanUp());
+
+ doCleanUp(cleanUpRefactoring);
+ }
+
+ private void doCleanUp(CleanUpRefactoring refactoring) throws CoreException {
+ refactoring.setUseOptionsFromProfile(true);
+
+ performRefactoring(refactoring, false, IStatus.WARNING, true);
+ performRefactoring(refactoring, false, IStatus.WARNING, true);
+
+ for (int i= 0; i < 10; i++) {
+ performRefactoring(refactoring, true, IStatus.WARNING, true);
+ }
+
+ commitMeasurements();
+ assertPerformanceInRelativeBand(Dimension.ELAPSED_PROCESS, -100, +10);
+ }
+
+ private void performRefactoring(CleanUpRefactoring refactoring, boolean measure, int maxSeverity, boolean checkUndo) throws CoreException {
+
+ // Need to clear the options field as we reuse the clean ups, which is not expected
+ clearOptions(refactoring.getCleanUps());
+
+ PerformRefactoringOperation operation= new PerformRefactoringOperation(refactoring, CheckConditionsOperation.ALL_CONDITIONS);
+ joinBackgroudActivities();
+ // Flush the undo manager to not count any already existing undo objects
+ // into the heap consumption
+ RefactoringCore.getUndoManager().flush();
+ System.gc();
+ if (measure)
+ startMeasuring();
+ ResourcesPlugin.getWorkspace().run(operation, null);
+ if (measure)
+ stopMeasuring();
+ assertEquals(true, operation.getConditionStatus().getSeverity() <= maxSeverity);
+ assertEquals(true, operation.getValidationStatus().isOK());
+ if (checkUndo) {
+ assertNotNull(operation.getUndoChange());
+ }
+ //undo the change, to have same code for each run
+ RefactoringCore.getUndoManager().performUndo(null, null);
+ RefactoringCore.getUndoManager().flush();
+ System.gc();
+ joinBackgroudActivities();
+ }
+
+ private void clearOptions(ICleanUp[] cleanUps) {
+ for (int i= 0; i < cleanUps.length; i++) {
+ ICleanUp cleanUp= cleanUps[i];
+ if (cleanUp instanceof AbstractCleanUp) {
+ Accessor accessor= new Accessor(cleanUp, AbstractCleanUp.class);
+ accessor.set("fOptions", null);
+ }
+ }
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/MockupPackageExplorerPart.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/MockupPackageExplorerPart.java
new file mode 100644
index 000000000..78d7b190e
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/MockupPackageExplorerPart.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.performance.views;
+
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart;
+
+public final class MockupPackageExplorerPart extends PackageExplorerPart {
+
+ public static PackageExplorerColdPerfTest fgTest= null;
+
+ public MockupPackageExplorerPart() {
+ super();
+ }
+
+ public final void createPartControl(Composite parent) {
+ if (fgTest != null) {
+ fgTest.startMeasuring();
+ }
+ super.createPartControl(parent);
+ if (fgTest != null)
+ fgTest.finishMeasurements();
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OpenTypePerfTest.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OpenTypePerfTest.java
new file mode 100644
index 000000000..0b807c21b
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OpenTypePerfTest.java
@@ -0,0 +1,235 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.performance.views;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+import org.eclipse.jdt.testplugin.OrderedTestSuite;
+import org.eclipse.jdt.testplugin.util.DisplayHelper;
+import org.eclipse.test.performance.Dimension;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.dialogs.SelectionDialog;
+
+import org.eclipse.jdt.core.search.SearchEngine;
+
+import org.eclipse.jdt.ui.IJavaElementSearchConstants;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jdt.ui.dialogs.TypeSelectionExtension;
+import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase;
+import org.eclipse.jdt.ui.tests.performance.SWTTestProject;
+
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+import org.eclipse.jdt.internal.ui.util.CoreUtility;
+
+public class OpenTypePerfTest extends JdtPerformanceTestCase {
+
+ private SelectionDialog fOpenTypeDialog;
+ private Shell fShell;
+
+ private static class MyTestSetup extends TestSetup {
+ private SWTTestProject fTestProject;
+ private boolean fAutoBuilding;
+
+ public MyTestSetup(Test test) {
+ super(test);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ fAutoBuilding= CoreUtility.setAutoBuilding(false);
+ fTestProject= new SWTTestProject();
+ }
+
+ protected void tearDown() throws Exception {
+ fTestProject.delete();
+ CoreUtility.setAutoBuilding(fAutoBuilding);
+ super.tearDown();
+ }
+ }
+
+ public static Test suite() throws Exception {
+ OrderedTestSuite testSuite= new OrderedTestSuite(
+ OpenTypePerfTest.class,
+ new String[] {
+ "testColdException",
+ "testWarmException",
+ "testWarmException10",
+ "testWarmS10",
+ "testWarmOpenSWT",
+ "testWarmOpenSWTHistory10",
+ });
+ return new MyTestSetup(testSuite);
+ }
+
+ public static Test setUpTest(Test someTest) {
+ return new MyTestSetup(someTest);
+ }
+
+ public OpenTypePerfTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ System.out.println("starting " + OpenTypePerfTest.class.getName() + "#" + getName());
+ super.setUp();
+ }
+
+ //---
+
+ public void testColdException() throws Exception {
+ //cold
+ try {
+ measureOpenType("*Exception");
+ } finally {
+ commitMeasurements();
+ assertPerformanceInRelativeBand(Dimension.ELAPSED_PROCESS, -100, +10);
+ }
+ }
+
+ public void testWarmException() throws Exception {
+ //warm
+ joinBackgroudActivities();
+ try {
+ measureOpenType("*Exception");
+ } finally {
+ commitMeasurements();
+ assertPerformanceInRelativeBand(Dimension.ELAPSED_PROCESS, -100, +10);
+ }
+ }
+
+ public void testWarmException10() throws Exception {
+ //warm, repeated
+ joinBackgroudActivities();
+ try {
+ for (int i= 0; i < 10; i++) {
+ measureOpenType("*Exception");
+ }
+ } finally {
+ commitMeasurements();
+ assertPerformanceInRelativeBand(Dimension.ELAPSED_PROCESS, -100, +10);
+ }
+ }
+
+ public void testWarmS10() throws Exception {
+ //warm, repeated, many matches
+ joinBackgroudActivities();
+ try {
+ for (int i= 0; i < 10; i++) {
+ measureOpenType("S");
+ }
+ } finally {
+ commitMeasurements();
+ assertPerformanceInRelativeBand(Dimension.ELAPSED_PROCESS, -100, +10);
+ }
+ }
+
+ public void testWarmOpenSWT() throws Exception {
+ //warm, add SWT to history
+ joinBackgroudActivities();
+ try {
+ measureOpenType("SWT", true);
+ } finally {
+ commitMeasurements();
+ assertPerformanceInRelativeBand(Dimension.ELAPSED_PROCESS, -100, +10);
+ }
+ }
+
+ public void testWarmOpenSWTHistory10() throws Exception {
+ //warm, repeated, open SWT from history
+ joinBackgroudActivities();
+ try {
+ for (int i= 0; i < 10; i++) {
+ measureOpenType("SWT", true);
+ }
+ } finally {
+ commitMeasurements();
+ assertPerformanceInRelativeBand(Dimension.ELAPSED_PROCESS, -100, +10);
+ }
+ }
+
+ //---
+
+ private void measureOpenType(String pattern) throws Exception {
+ measureOpenType(pattern, false);
+ }
+
+ private void measureOpenType(String pattern, final boolean openFirst) throws Exception {
+ fShell= JavaPlugin.getActiveWorkbenchShell();
+
+ startMeasuring();
+
+ fOpenTypeDialog= JavaUI.createTypeDialog(
+ fShell,
+ JavaPlugin.getActiveWorkbenchWindow(),
+ SearchEngine.createWorkspaceScope(),
+ IJavaElementSearchConstants.CONSIDER_ALL_TYPES,
+ false,
+ pattern,
+ new TypeSelectionExtension() {
+ public ISelectionStatusValidator getSelectionValidator() {
+ return new ISelectionStatusValidator() {
+ public IStatus validate(Object[] selection) {
+ finish(openFirst);
+ return Status.OK_STATUS;
+ }
+ };
+ }
+ });
+
+ try {
+ fOpenTypeDialog.setBlockOnOpen(false);
+ fOpenTypeDialog.open();
+ new DisplayHelper() {
+ protected boolean condition() {
+ return fOpenTypeDialog == null;
+ }
+ }.waitForCondition(fShell.getDisplay(), 60 * 1000, 10 * 1000);
+
+ } finally {
+ if (fOpenTypeDialog != null) {
+ finish(openFirst);
+ fail("took too long");
+ }
+ }
+ }
+
+ private void finish(final boolean openFirst) {
+ final SelectionDialog openTypeDialog= fOpenTypeDialog;
+ fOpenTypeDialog= null;
+
+ if (! openFirst) {
+ stopMeasuring();
+ fShell.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ openTypeDialog.close();
+ }
+ });
+
+ } else {
+ fShell.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ openTypeDialog.getOkButton().notifyListeners(SWT.Selection, new Event());
+ stopMeasuring();
+ }
+ });
+ }
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OrganizeImportsPerfTest.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OrganizeImportsPerfTest.java
new file mode 100644
index 000000000..3395df514
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OrganizeImportsPerfTest.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.performance.views;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.jdt.testplugin.JavaProjectHelper;
+import org.eclipse.jdt.testplugin.JavaTestPlugin;
+import org.eclipse.test.performance.Performance;
+import org.eclipse.test.performance.PerformanceMeter;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+
+import org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImportsOperation;
+
+import org.eclipse.jdt.ui.SharedASTProvider;
+import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase;
+
+public class OrganizeImportsPerfTest extends JdtPerformanceTestCase {
+
+ private static class MyTestSetup extends TestSetup {
+ public static final String SRC_CONTAINER= "src";
+
+ public static IJavaProject fJProject1;
+
+ public MyTestSetup(Test test) {
+ super(test);
+ }
+
+ protected void setUp() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ assertTrue("rt not found", JavaProjectHelper.addRTJar(fJProject1) != null);
+ File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
+ JavaProjectHelper.addSourceContainerWithImport(fJProject1, SRC_CONTAINER, junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
+ }
+
+ protected void tearDown() throws Exception {
+ if (fJProject1 != null && fJProject1.exists())
+ JavaProjectHelper.delete(fJProject1);
+ }
+ }
+
+ public static Test suite() {
+ return new MyTestSetup(new TestSuite(OrganizeImportsPerfTest.class));
+ }
+
+ public static Test setUpTest(Test someTest) {
+ return new MyTestSetup(someTest);
+ }
+
+ private void addAllCUs(IJavaElement[] children, List result) throws JavaModelException {
+ for (int i= 0; i < children.length; i++) {
+ IJavaElement element= children[i];
+ if (element instanceof ICompilationUnit) {
+ result.add(element);
+ } else if (element instanceof IPackageFragmentRoot) {
+ IPackageFragmentRoot root= ((IPackageFragmentRoot)element);
+ addAllCUs(root.getChildren(), result);
+ } else if (element instanceof IPackageFragment) {
+ IPackageFragment pack= ((IPackageFragment)element);
+ addAllCUs(pack.getChildren(), result);
+ }
+ }
+ }
+
+ private CompilationUnit[] createASTs(ICompilationUnit[] cus) {
+ CompilationUnit[] result= new CompilationUnit[cus.length];
+ for (int i= 0; i < cus.length; i++) {
+ result[i]= SharedASTProvider.getAST(cus[i], SharedASTProvider.WAIT_YES, new NullProgressMonitor());
+ }
+ return result;
+ }
+
+ public void testOrganizeImport() throws Exception {
+ measure(Performance.getDefault().getNullPerformanceMeter(), 10);
+ measure(fPerformanceMeter, 10);
+
+ // test is too short and hence the relative numbers spread too far (but still in an acceptable absolute band)
+// tagAsSummary("Organize Imports", Dimension.ELAPSED_PROCESS);
+
+ commitMeasurements();
+ Performance.getDefault().assertPerformance(fPerformanceMeter);
+ }
+
+ private void measure(PerformanceMeter performanceMeter, int runs) throws Exception {
+ for (int j= 0; j < runs; j++) {
+ List cusList= new ArrayList();
+ addAllCUs(MyTestSetup.fJProject1.getChildren(), cusList);
+ ICompilationUnit[] cus= (ICompilationUnit[])cusList.toArray(new ICompilationUnit[cusList.size()]);
+ CompilationUnit[] roots= createASTs(cus);
+
+ joinBackgroudActivities();
+
+ performanceMeter.start();
+ for (int i= 0; i < roots.length; i++) {
+ OrganizeImportsOperation op= new OrganizeImportsOperation(cus[i], roots[i], true, true, true, null);
+ op.run(new NullProgressMonitor());
+ }
+ performanceMeter.stop();
+ }
+
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerColdPerfTest.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerColdPerfTest.java
new file mode 100644
index 000000000..bef9ab0d7
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerColdPerfTest.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.performance.views;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.test.performance.Dimension;
+import org.eclipse.test.performance.Performance;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase;
+
+public class PackageExplorerColdPerfTest extends JdtPerformanceTestCase {
+
+ public static Test setUpTest(Test someTest) {
+ return new TestSetup(someTest);
+ }
+
+ public static Test suite() {
+ TestSuite suite= new TestSuite("PackageExplorerColdPerfTest");
+ suite.addTest(new PackageExplorerColdPerfTest("testOpen"));
+ return new TestSetup(suite);
+ }
+
+ public PackageExplorerColdPerfTest(String name) {
+ super(name);
+ }
+
+ public final void finishMeasurements() {
+ stopMeasuring();
+ commitMeasurements();
+ Performance.getDefault().assertPerformanceInAbsoluteBand(fPerformanceMeter, Dimension.ELAPSED_PROCESS, 0, 80);
+ }
+
+ public final void startMeasuring() {
+ super.startMeasuring();
+ }
+
+ public void testOpen() throws Exception {
+ IWorkbenchWindow activeWorkbenchWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page= activeWorkbenchWindow.getActivePage();
+ page.close();
+ page= activeWorkbenchWindow.openPage("org.eclipse.ui.resourcePerspective", ResourcesPlugin.getWorkspace().getRoot());
+ joinBackgroudActivities();
+ MockupPackageExplorerPart.fgTest= this;
+ page.showView("org.eclipse.jdt.ui.tests.MockPackageExplorer");
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerEmptyPerfTest.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerEmptyPerfTest.java
new file mode 100644
index 000000000..2a7bb3b97
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerEmptyPerfTest.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.performance.views;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase;
+
+public class PackageExplorerEmptyPerfTest extends JdtPerformanceTestCase {
+
+ public static Test setUpTest(Test someTest) {
+ return new TestSetup(someTest);
+ }
+
+ public static Test suite() {
+ TestSuite suite= new TestSuite("PackageExplorerEmptyPerfTest");
+ suite.addTest(new PackageExplorerEmptyPerfTest("testOpen"));
+ return new TestSetup(suite);
+ }
+
+ public PackageExplorerEmptyPerfTest(String name) {
+ super(name);
+ }
+
+ public void testOpen() throws Exception {
+ IWorkbenchWindow activeWorkbenchWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page= activeWorkbenchWindow.getActivePage();
+ page.close();
+ page= activeWorkbenchWindow.openPage("org.eclipse.ui.resourcePerspective", ResourcesPlugin.getWorkspace().getRoot());
+ joinBackgroudActivities();
+ startMeasuring();
+ page.showView(JavaUI.ID_PACKAGES);
+ finishMeasurements();
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerPerfTest.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerPerfTest.java
new file mode 100644
index 000000000..90182dd82
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerPerfTest.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.ui.tests.performance.views;
+
+import java.io.File;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.jdt.testplugin.JavaProjectHelper;
+import org.eclipse.jdt.testplugin.JavaTestPlugin;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.jdt.core.IJavaProject;
+
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase;
+
+import org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart;
+
+public class PackageExplorerPerfTest extends JdtPerformanceTestCase {
+
+ private static class MyTestSetup extends TestSetup {
+ public static final String SRC_CONTAINER= "src";
+
+ public static IJavaProject fJProject1;
+
+ public MyTestSetup(Test test) {
+ super(test);
+ }
+ protected void setUp() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("Testing", "bin");
+ // we must make sure that the performance test are compatible to 2.1.3 & 3.0 so use rt13
+ assertTrue("rt not found", JavaProjectHelper.addRTJar13(fJProject1) != null);
+ File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
+ JavaProjectHelper.addSourceContainerWithImport(fJProject1, SRC_CONTAINER, junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
+ }
+ protected void tearDown() throws Exception {
+ if (fJProject1 != null && fJProject1.exists())
+ JavaProjectHelper.delete(fJProject1);
+ }
+ }
+
+ public static Test suite() {
+ TestSuite suite= new TestSuite("PackageExplorerPerfTest");
+ suite.addTest(new PackageExplorerPerfTest("testOpen"));
+ suite.addTest(new PackageExplorerPerfTest("testSelect"));
+ suite.addTest(new PackageExplorerPerfTest("testExpand"));
+ return new MyTestSetup(suite);
+ }
+
+ public static Test setUpTest(Test someTest) {
+ return new MyTestSetup(someTest);
+ }
+
+ public PackageExplorerPerfTest(String name) {
+ super(name);
+ }
+
+ public void testOpen() throws Exception {
+ IWorkbenchWindow activeWorkbenchWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page= activeWorkbenchWindow.getActivePage();
+ page.close();
+ page= activeWorkbenchWindow.openPage("org.eclipse.ui.resourcePerspective", ResourcesPlugin.getWorkspace().getRoot());
+ joinBackgroudActivities();
+ startMeasuring();
+ page.showView(JavaUI.ID_PACKAGES);
+ finishMeasurements();
+ }
+
+ public void testSelect() throws Exception {
+ joinBackgroudActivities();
+ TreeViewer viewer= getViewer();
+ StructuredSelection selection= new StructuredSelection(MyTestSetup.fJProject1);
+ startMeasuring();
+ viewer.setSelection(selection);
+ finishMeasurements();
+ }
+
+ public void testExpand() throws Exception {
+ joinBackgroudActivities();
+ TreeViewer viewer= getViewer();
+ startMeasuring();
+ viewer.expandToLevel(MyTestSetup.fJProject1, 1);
+ finishMeasurements();
+ }
+
+ private TreeViewer getViewer() {
+ IWorkbenchPage page= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ return ((PackageExplorerPart)page.findView(JavaUI.ID_PACKAGES)).getTreeViewer();
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWarmPerfTest.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWarmPerfTest.java
new file mode 100644
index 000000000..11a98e0b9
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWarmPerfTest.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.performance.views;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.test.performance.Dimension;
+import org.eclipse.test.performance.Performance;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase;
+
+public class PackageExplorerWarmPerfTest extends JdtPerformanceTestCase {
+
+ public static Test setUpTest(Test someTest) {
+ return new TestSetup(someTest);
+ }
+
+ public static Test suite() {
+ TestSuite suite= new TestSuite("PackageExplorerWarmPerfTest");
+ suite.addTest(new PackageExplorerWarmPerfTest("testOpen"));
+ return new TestSetup(suite);
+ }
+
+ public PackageExplorerWarmPerfTest(String name) {
+ super(name);
+ }
+
+ public void testOpen() throws Exception {
+ IWorkbenchWindow activeWorkbenchWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page= activeWorkbenchWindow.getActivePage();
+ page.close();
+ page= activeWorkbenchWindow.openPage("org.eclipse.ui.resourcePerspective", ResourcesPlugin.getWorkspace().getRoot());
+ joinBackgroudActivities();
+ page.showView(JavaUI.ID_PACKAGES);
+ for (int i = 0; i < 10; i++) {
+ page.close();
+ page= activeWorkbenchWindow.openPage("org.eclipse.ui.resourcePerspective", ResourcesPlugin.getWorkspace().getRoot());
+ joinBackgroudActivities();
+ startMeasuring();
+ page.showView(JavaUI.ID_PACKAGES);
+ stopMeasuring();
+ }
+ commitMeasurements();
+ // don't spend more than 500 ms.
+ Performance.getDefault().assertPerformanceInAbsoluteBand(fPerformanceMeter, Dimension.ELAPSED_PROCESS, 0, 500);
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWorkspacePerfTest.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWorkspacePerfTest.java
new file mode 100644
index 000000000..748641c2f
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWorkspacePerfTest.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.ui.tests.performance.views;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase;
+
+public class PackageExplorerWorkspacePerfTest extends JdtPerformanceTestCase {
+
+ private static class MyTestSetup extends TestSetup {
+
+ public MyTestSetup(Test test) {
+ super(test);
+ }
+
+ protected void setUp() throws Exception {
+// IJavaModel model= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
+// if (model.getJavaProjects().length == 0) {
+// ExternalModelManager manager= PDECore.getDefault().getExternalModelManager();
+// IPluginModelBase[] allModels= manager.getAllModels();
+// PluginImportOperation op= new PluginImportOperation(allModels, PluginImportOperation.IMPORT_BINARY_WITH_LINKS, new PluginImportOperation.IReplaceQuery() {
+//
+// public int doQuery(IProject project) {
+// return YES;
+// }
+// });
+// ResourcesPlugin.getWorkspace().run(op, new NullProgressMonitor());
+// }
+ }
+
+ protected void tearDown() throws Exception {
+ }
+ }
+
+ public static Test suite() {
+ TestSuite suite= new TestSuite("PackageExplorerWorkspacePerfTest");
+ suite.addTest(new PackageExplorerWorkspacePerfTest("testOpen"));
+ return new MyTestSetup(suite);
+ }
+
+ public static Test setUpTest(Test someTest) {
+ return new MyTestSetup(someTest);
+ }
+
+ public PackageExplorerWorkspacePerfTest(String name) {
+ super(name);
+ }
+
+ public void testOpen() throws Exception {
+ IWorkbenchWindow activeWorkbenchWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page= activeWorkbenchWindow.getActivePage();
+ page.close();
+ page= activeWorkbenchWindow.openPage("org.eclipse.ui.resourcePerspective", ResourcesPlugin.getWorkspace().getRoot());
+ joinBackgroudActivities();
+ startMeasuring();
+ page.showView(JavaUI.ID_PACKAGES);
+ finishMeasurements();
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWorkspaceWarmPerfTest.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWorkspaceWarmPerfTest.java
new file mode 100644
index 000000000..addf39350
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWorkspaceWarmPerfTest.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.performance.views;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase;
+
+public class PackageExplorerWorkspaceWarmPerfTest extends JdtPerformanceTestCase {
+
+ private static class MyTestSetup extends TestSetup {
+
+ public MyTestSetup(Test test) {
+ super(test);
+ }
+
+ protected void setUp() throws Exception {
+// IJavaModel model= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
+// if (model.getJavaProjects().length == 0) {
+// ExternalModelManager manager= PDECore.getDefault().getExternalModelManager();
+// IPluginModelBase[] allModels= manager.getAllModels();
+// PluginImportOperation op= new PluginImportOperation(allModels, PluginImportOperation.IMPORT_BINARY_WITH_LINKS, new PluginImportOperation.IReplaceQuery() {
+//
+// public int doQuery(IProject project) {
+// return YES;
+// }
+// });
+// ResourcesPlugin.getWorkspace().run(op, new NullProgressMonitor());
+// }
+ }
+
+ protected void tearDown() throws Exception {
+ }
+ }
+
+ public static Test setUpTest(Test someTest) {
+ return new MyTestSetup(someTest);
+ }
+
+ public static Test suite() {
+ TestSuite suite= new TestSuite("PackageExplorerWorkspaceWarmPerfTest");
+ suite.addTest(new PackageExplorerWorkspaceWarmPerfTest("testOpen"));
+ return new MyTestSetup(suite);
+ }
+
+ public PackageExplorerWorkspaceWarmPerfTest(String name) {
+ super(name);
+ }
+
+ public void testOpen() throws Exception {
+ IWorkbenchWindow activeWorkbenchWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page= activeWorkbenchWindow.getActivePage();
+ page.close();
+ page= activeWorkbenchWindow.openPage("org.eclipse.ui.resourcePerspective", ResourcesPlugin.getWorkspace().getRoot());
+ joinBackgroudActivities();
+ page.showView(JavaUI.ID_PACKAGES);
+ page.close();
+ page= activeWorkbenchWindow.openPage("org.eclipse.ui.resourcePerspective", ResourcesPlugin.getWorkspace().getRoot());
+ startMeasuring();
+ page.showView(JavaUI.ID_PACKAGES);
+ finishMeasurements();
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/TypeHierarchyPerfTest.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/TypeHierarchyPerfTest.java
new file mode 100644
index 000000000..4d76a6c10
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/TypeHierarchyPerfTest.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.performance.views;
+
+import java.io.File;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+import org.eclipse.jdt.testplugin.JavaProjectHelper;
+import org.eclipse.jdt.testplugin.JavaTestPlugin;
+import org.eclipse.jdt.testplugin.OrderedTestSuite;
+import org.eclipse.test.performance.Dimension;
+import org.eclipse.test.performance.Performance;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase;
+
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+import org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyViewPart;
+import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil;
+
+public class TypeHierarchyPerfTest extends JdtPerformanceTestCase {
+
+ private static class MyTestSetup extends TestSetup {
+ public static final String SRC_CONTAINER= "src";
+
+ public static IJavaProject fJProject1;
+ public static IPackageFragmentRoot fJunitSrcRoot;
+
+ public MyTestSetup(Test test) {
+ super(test);
+ }
+
+ protected void setUp() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ // we must make sure that the performance test are compatible to 2.1.3 & 3.0 so use rt13
+ assertTrue("rt not found", JavaProjectHelper.addRTJar13(fJProject1) != null);
+ File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
+ fJunitSrcRoot= JavaProjectHelper.addSourceContainerWithImport(fJProject1, SRC_CONTAINER, junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
+ }
+
+ protected void tearDown() throws Exception {
+ if (fJProject1 != null && fJProject1.exists())
+ JavaProjectHelper.delete(fJProject1);
+ }
+ }
+
+ public static Test suite() {
+ OrderedTestSuite testSuite= new OrderedTestSuite(
+ TypeHierarchyPerfTest.class,
+ new String[] {
+ "testOpenObjectHierarchy",
+ "testOpenCollHierarchy",
+ "testOpenObjectHierarchy2",
+ });
+ return new MyTestSetup(testSuite);
+ }
+
+ public static Test setUpTest(Test someTest) {
+ return new MyTestSetup(someTest);
+ }
+
+ public TypeHierarchyPerfTest(String name) {
+ super(name);
+ }
+
+ public void testOpenObjectHierarchy() throws Exception {
+ //cold
+
+ // make sure stuff like the Intro view gets closed and we start with a clean Java perspective:
+ IWorkbenchWindow activeWorkbenchWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page= activeWorkbenchWindow.getActivePage();
+ page.close();
+ page= activeWorkbenchWindow.openPage(JavaUI.ID_PERSPECTIVE, ResourcesPlugin.getWorkspace().getRoot());
+
+ measureOpenHierarchy(MyTestSetup.fJProject1.findType("java.lang.Object"));
+ Performance.getDefault().assertPerformanceInAbsoluteBand(fPerformanceMeter, Dimension.ELAPSED_PROCESS, 0, 2000);
+ }
+
+ public void testOpenCollHierarchy() throws Exception {
+ //junit source folder
+ measureOpenHierarchy(MyTestSetup.fJunitSrcRoot);
+ Performance.getDefault().assertPerformanceInAbsoluteBand(fPerformanceMeter, Dimension.ELAPSED_PROCESS, 0, 1000);
+ }
+
+ public void testOpenObjectHierarchy2() throws Exception {
+ //warm
+ tagAsSummary("Open type hierarchy on Object", Dimension.ELAPSED_PROCESS);
+
+ IJavaElement element= MyTestSetup.fJProject1.findType("java.lang.Object");
+ IWorkbenchWindow workbenchWindow= JavaPlugin.getActiveWorkbenchWindow();
+
+ TypeHierarchyViewPart viewPart= OpenTypeHierarchyUtil.open(element, workbenchWindow);
+
+ for (int i= 0; i < 10; i++) {
+ viewPart.setInputElement(MyTestSetup.fJProject1.findType("java.lang.String"));
+ viewPart.getSite().getPage().hideView(viewPart);
+
+ joinBackgroudActivities();
+ startMeasuring();
+ viewPart= OpenTypeHierarchyUtil.open(element, workbenchWindow);
+ stopMeasuring();
+ }
+
+ commitMeasurements();
+ assertPerformanceInRelativeBand(Dimension.ELAPSED_PROCESS, -100, +10);
+ }
+
+ private void measureOpenHierarchy(IJavaElement element) throws Exception {
+ IWorkbenchWindow activeWorkbenchWindow= JavaPlugin.getActiveWorkbenchWindow();
+ joinBackgroudActivities();
+
+ startMeasuring();
+
+ OpenTypeHierarchyUtil.open(element, activeWorkbenchWindow);
+
+ stopMeasuring();
+ commitMeasurements();
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/ViewPerformanceTests.java b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/ViewPerformanceTests.java
new file mode 100644
index 000000000..eec216808
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/ViewPerformanceTests.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+ package org.eclipse.jdt.ui.tests.performance.views;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class ViewPerformanceTests extends TestCase {
+ public static Test suite() {
+ TestSuite suite= new TestSuite("View Performance Tests"); //$NON-NLS-1$
+ suite.addTest(PackageExplorerPerfTest.suite());
+ suite.addTest(PackageExplorerColdPerfTest.suite());
+ suite.addTest(PackageExplorerEmptyPerfTest.suite());
+ suite.addTest(PackageExplorerWarmPerfTest.suite());
+ suite.addTest(PackageExplorerWorkspacePerfTest.suite());
+ suite.addTest(PackageExplorerWorkspaceWarmPerfTest.suite());
+ suite.addTest(TypeHierarchyPerfTest.suite());
+ return suite;
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/plugin.properties b/testplugins/org.eclipse.jdt.ui.tests/plugin.properties
new file mode 100644
index 000000000..39c928eb7
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/plugin.properties
@@ -0,0 +1,21 @@
+###############################################################################
+# Copyright (c) 2000, 2005 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
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+
+Plugin.name= Java Test Plug-in
+Plugin.providerName= Eclipse.org
+TestLabelDecorator.label= JDT UI Test Decorator
+TestLightweightLabelDecorator.label= JDT UI Test Lightweight Decorator
+
+AddTestMarkersAction.label= Add Test Markers
+AddTestMarkersAction.tooltip= Add Test Markers
+
+exampleQuickFixProcessor.name= Example Quick Fix Processor
+exampleQuickAssistProcessor.name= Example Quick Assist Processor
diff --git a/testplugins/org.eclipse.jdt.ui.tests/plugin.xml b/testplugins/org.eclipse.jdt.ui.tests/plugin.xml
new file mode 100644
index 000000000..b05100687
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/plugin.xml
@@ -0,0 +1,272 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+
+<!-- **************** TEST DECORATOR ******************* -->
+ <extension
+ point="org.eclipse.ui.decorators">
+ <decorator
+ adaptable="true"
+ label="%TestLabelDecorator.label"
+ state="false"
+ class="org.eclipse.jdt.ui.examples.JavaElementDecorator"
+ id="org.eclipse.jdt.ui.examples.javaElementDecorator">
+ <enablement>
+ <objectClass name="org.eclipse.jdt.core.IJavaElement"/>
+ </enablement>
+ <description>
+ Appends an asterisk (*) to all IJavaElements.
+ </description>
+ </decorator>
+
+ <decorator
+ label="%TestLightweightLabelDecorator.label"
+ lightweight="true"
+ location="BOTTOM_LEFT"
+ state="true"
+ class="org.eclipse.jdt.ui.examples.JavaElementLightweightDecorator"
+ id="org.eclipse.jdt.ui.examples.javaElementLightweightDecorator">
+ <enablement>
+ <or>
+ <objectClass
+ name="org.eclipse.core.resources.IResource">
+ </objectClass>
+ <objectClass
+ name="org.eclipse.jdt.core.IJavaElement">
+ </objectClass>
+ </or>
+ </enablement>
+ <description>
+ Renders files with open FileBuffers bold.
+ </description>
+ </decorator>
+
+ </extension>
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ name="MochPluginView"
+ class="org.eclipse.jdt.ui.tests.packageview.MockPluginView"
+ id="org.eclipse.jdt.ui.tests.packageview.MockPluginView">
+ </view>
+ <view
+ name="MockPluginView"
+ class="org.eclipse.jdt.ui.tests.browsing.MockPluginView"
+ id="org.eclipse.jdt.ui.tests.browsing.MockPluginView">
+ </view>
+ <view
+ name="MockPluginView"
+ class="org.eclipse.jdt.ui.tests.model.MockPluginView"
+ id="org.eclipse.jdt.ui.tests.model.MockPluginView">
+ </view>
+ <view
+ allowMultiple="true"
+ class="org.eclipse.jdt.ui.tests.performance.views.MockupPackageExplorerPart"
+ id="org.eclipse.jdt.ui.tests.MockPackageExplorer"
+ name="Package Explorer Mock View"/>
+ </extension>
+<!-- **************** TEST MARKER for quick fix ******************* -->
+ <extension
+ id="testmarker"
+ name="jdt-test-problem"
+ point="org.eclipse.core.resources.markers">
+ <super type="org.eclipse.core.resources.problemmarker"/>
+ <super type="org.eclipse.core.resources.textmarker"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.editors.annotationTypes">
+ <type
+ name="org.eclipse.jdt.ui.testproblem"
+ super="org.eclipse.ui.workbench.texteditor.error"
+ markerType="org.eclipse.jdt.ui.tests.testmarker"
+ markerSeverity="2">
+ </type>
+ </extension>
+
+ <extension point="org.eclipse.ui.ide.markerSupport">
+ <markerAttributeGrouping markerType="org.eclipse.jdt.ui.tests.testmarker"
+ defaultGroupingEntry="org.eclipse.jdt.ui.category.nls"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.ide.markerResolution">
+ <markerResolutionGenerator
+ markerType="org.eclipse.jdt.ui.tests.testmarker"
+ class="org.eclipse.jdt.ui.tests.quickfix.MarkerResolutionGenerator">
+ </markerResolutionGenerator>
+ </extension>
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ objectClass="org.eclipse.jdt.core.ICompilationUnit"
+ id="org.eclipse.jdt.ui.examples.AddTestMarkersAction">
+ <action
+ label="%AddTestMarkersAction.label"
+ tooltip="%AddTestMarkersAction.tooltip"
+ class="org.eclipse.jdt.ui.examples.AddTestMarkersAction"
+ menubarPath="AddTestMarkers"
+ enablesFor="1"
+ id="addTestmarkers">
+ </action>
+ </objectContribution>
+ </extension>
+ <extension
+ point="org.eclipse.jdt.ui.quickFixProcessors">
+ <quickFixProcessor
+ name="%exampleQuickFixProcessor.name"
+ class="org.eclipse.jdt.ui.examples.MyQuickFixProcessor"
+ requiredSourceLevel="1.5"
+ id="org.eclipse.jdt.ui.examples.MyQuickFixProcessor">
+ <enablement>
+ <with variable="compilationUnit">
+ <test property="org.eclipse.jdt.core.name" value="A.java"/>
+ </with>
+ </enablement>
+
+ </quickFixProcessor>
+ </extension>
+ <extension
+ point="org.eclipse.jdt.ui.quickAssistProcessors">
+ <quickAssistProcessor
+ name="%exampleQuickAssistProcessor.name"
+ class="org.eclipse.jdt.ui.examples.MyQuickAssistProcessor"
+ id="org.eclipse.jdt.ui.examples.MyQuickAssistProcessor">
+ <enablement>
+ <with variable="projectNatures">
+ <iterate operator="or">
+ <equals value="org.eclipse.jdt.core.javanature"/>
+ </iterate>
+ </with>
+ </enablement>
+ </quickAssistProcessor>
+ </extension>
+
+ <extension
+ point="org.eclipse.jdt.core.classpathContainerInitializer">
+ <classpathContainerInitializer
+ class="org.eclipse.jdt.ui.examples.MyClasspathContainerInitializer"
+ id="org.eclipse.jdt.EXAMPLE_CONTAINER">
+ </classpathContainerInitializer>
+ </extension>
+
+ <extension
+ point="org.eclipse.jdt.ui.classpathContainerPage">
+ <classpathContainerPage
+ name="My Example Container (jdt.ui.tests)"
+ class="org.eclipse.jdt.ui.examples.MyClasspathContainerPage"
+ id="org.eclipse.jdt.EXAMPLE_CONTAINER">
+ </classpathContainerPage>
+ </extension>
+
+ <extension
+ point="org.eclipse.jdt.ui.javadocExportWizardPage">
+ <javadocExportWizardPage
+ description="My Javadoc Export Wizard Page (jdt.ui.tests)"
+ class="org.eclipse.jdt.ui.examples.MyJavadocExportWizardPage"
+ id="org.eclipse.jdt.EXAMPLE_JD_EXPORT_WP">
+ </javadocExportWizardPage>
+ </extension>
+
+ <!-- **************** TEST NEW PROJECT WIZARD ******************* -->
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <wizard
+ id="org.eclipse.jdt.ui.examples.MyProjectCreationWizard"
+ name="In/Out Project (jdt.ui.tests)"
+ class="org.eclipse.jdt.ui.examples.MyProjectCreationWizard"
+ category="org.eclipse.jdt.ui.java"
+ project="true"
+ finalPerspective="org.eclipse.jdt.ui.JavaPerspective">
+ <description>In/Out Project (jdt.ui.tests)</description>
+ </wizard>
+</extension>
+
+ <extension point="org.eclipse.jdt.ui.javaElementFilters">
+ <filter
+ targetId="org.eclipse.jdt.ui.PackageExplorer"
+ name="Hide Java projects with other natures (jdt.ui.test)"
+ enabled="false"
+ description="Hide Java projects with other natures (jdt.ui.test)"
+ class="org.eclipse.jdt.ui.examples.filters.PureProjectFilter"
+ id="org.eclipse.jdt.internal.ui.PackageExplorer.PureProjectFilter">
+ </filter>
+ <filter
+ targetId="org.eclipse.jdt.ui.PackageExplorer"
+ name="Hide A.java (jdt.ui.test)"
+ enabled="false"
+ description="Hide A.java (jdt.ui.test)"
+ class="org.eclipse.jdt.ui.examples.filters.AFileFilter"
+ id="org.eclipse.jdt.internal.ui.PackageExplorer.AFileFilter">
+ </filter>
+ </extension>
+ <extension point="org.eclipse.ui.navigator.navigatorContent">
+ <commonFilter
+ activeByDefault="false"
+ class="org.eclipse.jdt.ui.examples.filters.AFileFilter"
+ name="Hide A.java (jdt.ui.test)"
+ description="Hide A.java (jdt.ui.test)"
+ id="org.eclipse.jdt.java.ui.filters.AFileFilter"/>
+ </extension>
+
+<!-- JavaLeakTest: -->
+ <extension
+ point="org.eclipse.ui.actionSets">
+ <actionSet
+ id="org.eclipse.jdt.ui.tests.actionSet1"
+ label="JavaLeakTest"
+ visible="true">
+ <action
+ definitionId="org.eclipse.jdt.ui.tests.JavaLeakTestActionDelegate"
+ label="JavaLeakTestActionDelegate"
+ class="org.eclipse.jdt.ui.tests.leaks.JavaLeakTestActionDelegate"
+ menubarPath="navigate/open.ext2"
+ enablesFor="*"
+ id="org.eclipse.jdt.ui.tests.actions.JavaLeakTestActionDelegate">
+ <enablement>
+ <objectClass
+ name="org.eclipse.jface.text.ITextSelection">
+ </objectClass>
+ </enablement>
+ </action>
+ </actionSet>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <viewerContribution
+ targetID="#TextEditorContext"
+ id="org.eclipse.jdt.ui.tests.PopupActions">
+ <visibility>
+ <objectClass
+ name="org.eclipse.jface.text.ITextSelection">
+ </objectClass>
+ </visibility>
+ <action
+ class="org.eclipse.jdt.ui.tests.leaks.JavaLeakTestActionDelegate"
+ definitionId="org.eclipse.jdt.ui.tests.JavaLeakTestActionDelegate"
+ enablesFor="*"
+ id="org.eclipse.jdt.ui.tests.actions.JavaLeakTestActionDelegate"
+ label="JavaLeakTestActionDelegate"
+ menubarPath="additions">
+ </action>
+ </viewerContribution>
+ </extension>
+
+ <extension point="org.eclipse.ui.commands">
+ <command
+ name="JavaLeakTestActionDelegate"
+ description="JavaLeakTestActionDelegate"
+ id="org.eclipse.jdt.ui.tests.JavaLeakTestActionDelegate">
+ </command>
+ </extension>
+
+ <extension point="org.eclipse.ui.bindings">
+ <key
+ sequence="M1+M2+M3+Q"
+ commandId="org.eclipse.jdt.ui.tests.JavaLeakTestActionDelegate"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+ </extension>
+<!-- End of JavaLeakTest -->
+
+</plugin>
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java
new file mode 100644
index 000000000..08dfdcaf3
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java
@@ -0,0 +1,819 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 83258 [jar exporter] Deploy java application as executable jar
+ * Technical University Berlin - adapted for Object Teams
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.zip.ZipFile;
+
+import junit.framework.Assert;
+
+import org.osgi.framework.Bundle;
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Synchronizer;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+import org.eclipse.ui.wizards.datatransfer.ImportOperation;
+import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
+
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.search.IJavaSearchConstants;
+import org.eclipse.jdt.core.search.SearchEngine;
+import org.eclipse.jdt.core.search.SearchPattern;
+import org.eclipse.jdt.core.search.TypeNameRequestor;
+
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+import org.eclipse.jdt.internal.ui.util.CoreUtility;
+
+
+/**
+ * Helper methods to set up a IJavaProject.
+ */
+public class JavaProjectHelper {
+
+ /**
+ * @deprecated
+ * @see #RT_STUBS_15
+ */
+ public static final IPath RT_STUBS_13= new Path("testresources/rtstubs.jar");
+ /**
+ * @deprecated
+ * @see #JUNIT_SRC_381
+ */
+ public static final IPath JUNIT_SRC= new Path("testresources/junit37-noUI-src.zip");
+
+ public static final IPath RT_STUBS_15= new Path("testresources/rtstubs15.jar");
+ public static final IPath RT_STUBS_16= new Path("testresources/rtstubs16.jar");
+ public static final IPath JUNIT_SRC_381= new Path("testresources/junit381-noUI-src.zip");
+ public static final String JUNIT_SRC_ENCODING= "ISO-8859-1";
+
+ public static final IPath MYLIB= new Path("testresources/mylib.jar");
+ public static final IPath MYLIB_STDOUT= new Path("testresources/mylib_stdout.jar");
+ public static final IPath MYLIB_SIG= new Path("testresources/mylib_sig.jar");
+ public static final IPath NLS_LIB= new Path("testresources/nls.jar");
+
+ private static final int MAX_RETRY= 5;
+
+ public static final int COUNT_CLASSES_RT_STUBS_15= 661;
+ public static final int COUNT_INTERFACES_RT_STUBS_15= 135;
+
+ public static final int COUNT_CLASSES_JUNIT_SRC_381= 76;
+ public static final int COUNT_INTERFACES_JUNIT_SRC_381= 8;
+ public static final int COUNT_CLASSES_MYLIB= 3;
+
+ /**
+ * If set to <code>true</code> all resources that are
+ * deleted using {@link #delete(IJavaElement)} and that contain mixed
+ * line delimiters will result in a test failure.
+ * <p>
+ * Should be <code>false</code> during normal and Releng test runs
+ * due to performance impact and because the search plug-in gets
+ * loaded which results in a test failure.
+ * </p>
+ */
+ private static final boolean ASSERT_NO_MIXED_LINE_DELIMIERS= false;
+
+ /**
+ * Creates a IJavaProject.
+ * @param projectName The name of the project
+ * @param binFolderName Name of the output folder
+ * @return Returns the Java project handle
+ * @throws CoreException Project creation failed
+ */
+ public static IJavaProject createJavaProject(String projectName, String binFolderName) throws CoreException {
+ IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
+ IProject project= root.getProject(projectName);
+ if (!project.exists()) {
+ project.create(null);
+ } else {
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+
+ if (!project.isOpen()) {
+ project.open(null);
+ }
+
+ IPath outputLocation;
+ if (binFolderName != null && binFolderName.length() > 0) {
+ IFolder binFolder= project.getFolder(binFolderName);
+ if (!binFolder.exists()) {
+ CoreUtility.createFolder(binFolder, false, true, null);
+ }
+ outputLocation= binFolder.getFullPath();
+ } else {
+ outputLocation= project.getFullPath();
+ }
+
+ if (!project.hasNature(JavaCore.NATURE_ID)) {
+ addNatureToProject(project, JavaCore.NATURE_ID, null);
+ }
+
+ IJavaProject jproject= JavaCore.create(project);
+
+ jproject.setOutputLocation(outputLocation, null);
+ jproject.setRawClasspath(new IClasspathEntry[0], null);
+
+ return jproject;
+ }
+
+ /**
+ * Creates a Java project with JUnit source and rt.jar from
+ * {@link #addVariableRTJar(IJavaProject, String, String, String)}.
+ *
+ * @param projectName the project name
+ * @param srcContainerName the source container name
+ * @param outputFolderName the output folder name
+ * @return the IJavaProject
+ * @throws CoreException
+ * @throws IOException
+ * @throws InvocationTargetException
+ * @since 3.1
+ */
+ public static IJavaProject createJavaProjectWithJUnitSource(String projectName, String srcContainerName, String outputFolderName) throws CoreException, IOException, InvocationTargetException {
+ IJavaProject project= createJavaProject(projectName, outputFolderName);
+
+ IPackageFragmentRoot jdk= JavaProjectHelper.addVariableRTJar(project, "JRE_LIB_TEST", null, null);//$NON-NLS-1$
+ Assert.assertNotNull(jdk);
+
+ File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JUNIT_SRC_381);
+ Assert.assertTrue(junitSrcArchive != null && junitSrcArchive.exists());
+
+ JavaProjectHelper.addSourceContainerWithImport(project, srcContainerName, junitSrcArchive, JUNIT_SRC_ENCODING);
+
+ return project;
+ }
+
+ /**
+ * Sets the compiler options to 1.5 for the given project.
+ * @param project the java project
+ */
+ public static void set15CompilerOptions(IJavaProject project) {
+ Map options= project.getOptions(false);
+ JavaProjectHelper.set15CompilerOptions(options);
+ project.setOptions(options);
+ }
+
+ /**
+ * Sets the compiler options to 1.4 for the given project.
+ * @param project the java project
+ */
+ public static void set14CompilerOptions(IJavaProject project) {
+ Map options= project.getOptions(false);
+ JavaProjectHelper.set14CompilerOptions(options);
+ project.setOptions(options);
+ }
+
+ /**
+ * Sets the compiler options to 1.6
+ * @param options The compiler options to configure
+ */
+ public static void set16CompilerOptions(Map options) {
+ options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_6);
+ options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);
+ options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR);
+ options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_6);
+ options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_6);
+ }
+
+ /**
+ * Sets the compiler options to 1.5
+ * @param options The compiler options to configure
+ */
+ public static void set15CompilerOptions(Map options) {
+ options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
+ options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);
+ options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR);
+ options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
+ options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5);
+ }
+
+ /**
+ * Sets the compiler options to 1.4
+ * @param options The compiler options to configure
+ */
+ public static void set14CompilerOptions(Map options) {
+ options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
+ options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);
+ options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.WARNING);
+ options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3);
+ options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2);
+ }
+
+ /**
+ * Sets the compiler options to 1.3
+ * @param options The compiler options to configure
+ */
+ public static void set13CompilerOptions(Map options) {
+ options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_3);
+ options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.WARNING);
+ options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.WARNING);
+ options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3);
+ options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2);
+ }
+
+ /**
+ * Removes a IJavaElement
+ *
+ * @param elem The element to remove
+ * @throws CoreException Removing failed
+ * @see #ASSERT_NO_MIXED_LINE_DELIMIERS
+ */
+ public static void delete(final IJavaElement elem) throws CoreException {
+ if (ASSERT_NO_MIXED_LINE_DELIMIERS)
+ MixedLineDelimiterDetector.assertNoMixedLineDelimiters(elem);
+
+ IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ performDummySearch();
+ if (elem instanceof IJavaProject) {
+ IJavaProject jproject= (IJavaProject) elem;
+ jproject.setRawClasspath(new IClasspathEntry[0], jproject.getProject().getFullPath(), null);
+ }
+ delete(elem.getResource());
+ }
+ };
+ ResourcesPlugin.getWorkspace().run(runnable, null);
+ emptyDisplayLoop();
+ }
+
+ public static void delete(IResource resource) throws CoreException {
+ for (int i= 0; i < MAX_RETRY; i++) {
+ try {
+ resource.delete(true, null);
+ i= MAX_RETRY;
+ } catch (CoreException e) {
+ if (i == MAX_RETRY - 1) {
+ JavaPlugin.log(e);
+ throw e;
+ }
+ try {
+ Thread.sleep(1000); // sleep a second
+ } catch (InterruptedException e1) {
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes all files in the project and sets the given classpath
+ * @param jproject The project to clear
+ * @param entries The default class path to set
+ * @throws Exception Clearing the project failed
+ */
+ public static void clear(final IJavaProject jproject, final IClasspathEntry[] entries) throws Exception {
+ performDummySearch();
+ IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ jproject.setRawClasspath(entries, null);
+
+ IResource[] resources= jproject.getProject().members();
+ for (int i= 0; i < resources.length; i++) {
+ if (!resources[i].getName().startsWith(".")) {
+ delete(resources[i]);
+ }
+ }
+ }
+ };
+ ResourcesPlugin.getWorkspace().run(runnable, null);
+
+ JavaProjectHelper.emptyDisplayLoop();
+ }
+
+
+ public static void performDummySearch() throws JavaModelException {
+ new SearchEngine().searchAllTypeNames(
+ null,
+ SearchPattern.R_EXACT_MATCH,
+ "XXXXXXXXX".toCharArray(), // make sure we search a concrete name. This is faster according to Kent
+ SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE,
+ IJavaSearchConstants.CLASS,
+ SearchEngine.createJavaSearchScope(new IJavaElement[0]),
+ new Requestor(),
+ IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
+ null);
+ }
+
+
+ /**
+ * Adds a source container to a IJavaProject.
+ * @param jproject The parent project
+ * @param containerName The name of the new source container
+ * @return The handle to the new source container
+ * @throws CoreException Creation failed
+ */
+ public static IPackageFragmentRoot addSourceContainer(IJavaProject jproject, String containerName) throws CoreException {
+ return addSourceContainer(jproject, containerName, new Path[0]);
+ }
+
+ /**
+ * Adds a source container to a IJavaProject.
+ * @param jproject The parent project
+ * @param containerName The name of the new source container
+ * @param exclusionFilters Exclusion filters to set
+ * @return The handle to the new source container
+ * @throws CoreException Creation failed
+ */
+ public static IPackageFragmentRoot addSourceContainer(IJavaProject jproject, String containerName, IPath[] exclusionFilters) throws CoreException {
+ return addSourceContainer(jproject, containerName, new Path[0], exclusionFilters);
+ }
+
+ /**
+ * Adds a source container to a IJavaProject.
+ * @param jproject The parent project
+ * @param containerName The name of the new source container
+ * @param inclusionFilters Inclusion filters to set
+ * @param exclusionFilters Exclusion filters to set
+ * @return The handle to the new source container
+ * @throws CoreException Creation failed
+ */
+ public static IPackageFragmentRoot addSourceContainer(IJavaProject jproject, String containerName, IPath[] inclusionFilters, IPath[] exclusionFilters) throws CoreException {
+ return addSourceContainer(jproject, containerName, inclusionFilters, exclusionFilters, null);
+ }
+
+ /**
+ * Adds a source container to a IJavaProject.
+ * @param jproject The parent project
+ * @param containerName The name of the new source container
+ * @param inclusionFilters Inclusion filters to set
+ * @param exclusionFilters Exclusion filters to set
+ * @param outputLocation The location where class files are written to, <b>null</b> for project output folder
+ * @return The handle to the new source container
+ * @throws CoreException Creation failed
+ */
+ public static IPackageFragmentRoot addSourceContainer(IJavaProject jproject, String containerName, IPath[] inclusionFilters, IPath[] exclusionFilters, String outputLocation) throws CoreException {
+ IProject project= jproject.getProject();
+ IContainer container= null;
+ if (containerName == null || containerName.length() == 0) {
+ container= project;
+ } else {
+ IFolder folder= project.getFolder(containerName);
+ if (!folder.exists()) {
+ CoreUtility.createFolder(folder, false, true, null);
+ }
+ container= folder;
+ }
+ IPackageFragmentRoot root= jproject.getPackageFragmentRoot(container);
+
+ IPath outputPath= null;
+ if (outputLocation != null) {
+ IFolder folder= project.getFolder(outputLocation);
+ if (!folder.exists()) {
+ CoreUtility.createFolder(folder, false, true, null);
+ }
+ outputPath= folder.getFullPath();
+ }
+ IClasspathEntry cpe= JavaCore.newSourceEntry(root.getPath(), inclusionFilters, exclusionFilters, outputPath);
+ addToClasspath(jproject, cpe);
+ return root;
+ }
+
+ /**
+ * Adds a source container to a IJavaProject and imports all files contained
+ * in the given ZIP file.
+ * @param jproject The parent project
+ * @param containerName Name of the source container
+ * @param zipFile Archive to import
+ * @param containerEncoding encoding for the generated source container
+ * @return The handle to the new source container
+ * @throws InvocationTargetException Creation failed
+ * @throws CoreException Creation failed
+ * @throws IOException Creation failed
+ */
+ public static IPackageFragmentRoot addSourceContainerWithImport(IJavaProject jproject, String containerName, File zipFile, String containerEncoding) throws InvocationTargetException, CoreException, IOException {
+ return addSourceContainerWithImport(jproject, containerName, zipFile, containerEncoding, new Path[0]);
+ }
+
+ /**
+ * Adds a source container to a IJavaProject and imports all files contained
+ * in the given ZIP file.
+ * @param jproject The parent project
+ * @param containerName Name of the source container
+ * @param zipFile Archive to import
+ * @param containerEncoding encoding for the generated source container
+ * @param exclusionFilters Exclusion filters to set
+ * @return The handle to the new source container
+ * @throws InvocationTargetException Creation failed
+ * @throws CoreException Creation failed
+ * @throws IOException Creation failed
+ */
+ public static IPackageFragmentRoot addSourceContainerWithImport(IJavaProject jproject, String containerName, File zipFile, String containerEncoding, IPath[] exclusionFilters) throws InvocationTargetException, CoreException, IOException {
+ ZipFile file= new ZipFile(zipFile);
+ try {
+ IPackageFragmentRoot root= addSourceContainer(jproject, containerName, exclusionFilters);
+ ((IContainer) root.getCorrespondingResource()).setDefaultCharset(containerEncoding, null);
+ importFilesFromZip(file, root.getPath(), null);
+ return root;
+ } finally {
+ file.close();
+ }
+ }
+
+ /**
+ * Removes a source folder from a IJavaProject.
+ * @param jproject The parent project
+ * @param containerName Name of the source folder to remove
+ * @throws CoreException Remove failed
+ */
+ public static void removeSourceContainer(IJavaProject jproject, String containerName) throws CoreException {
+ IFolder folder= jproject.getProject().getFolder(containerName);
+ removeFromClasspath(jproject, folder.getFullPath());
+ folder.delete(true, null);
+ }
+
+ /**
+ * Adds a library entry to a IJavaProject.
+ * @param jproject The parent project
+ * @param path The path of the library to add
+ * @return The handle of the created root
+ * @throws JavaModelException
+ */
+ public static IPackageFragmentRoot addLibrary(IJavaProject jproject, IPath path) throws JavaModelException {
+ return addLibrary(jproject, path, null, null);
+ }
+
+ /**
+ * Adds a library entry with source attachment to a IJavaProject.
+ * @param jproject The parent project
+ * @param path The path of the library to add
+ * @param sourceAttachPath The source attachment path
+ * @param sourceAttachRoot The source attachment root path
+ * @return The handle of the created root
+ * @throws JavaModelException
+ */
+ public static IPackageFragmentRoot addLibrary(IJavaProject jproject, IPath path, IPath sourceAttachPath, IPath sourceAttachRoot) throws JavaModelException {
+ IClasspathEntry cpe= JavaCore.newLibraryEntry(path, sourceAttachPath, sourceAttachRoot);
+ addToClasspath(jproject, cpe);
+ IResource workspaceResource= ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ if (workspaceResource != null) {
+ return jproject.getPackageFragmentRoot(workspaceResource);
+ }
+ return jproject.getPackageFragmentRoot(path.toString());
+ }
+
+
+ /**
+ * Copies the library into the project and adds it as library entry.
+ * @param jproject The parent project
+ * @param jarPath
+ * @param sourceAttachPath The source attachment path
+ * @param sourceAttachRoot The source attachment root path
+ * @return The handle of the created root
+ * @throws IOException
+ * @throws CoreException
+ */
+ public static IPackageFragmentRoot addLibraryWithImport(IJavaProject jproject, IPath jarPath, IPath sourceAttachPath, IPath sourceAttachRoot) throws IOException, CoreException {
+ IProject project= jproject.getProject();
+ IFile newFile= project.getFile(jarPath.lastSegment());
+ InputStream inputStream= null;
+ try {
+ inputStream= new FileInputStream(jarPath.toFile());
+ newFile.create(inputStream, true, null);
+ } finally {
+ if (inputStream != null) {
+ try { inputStream.close(); } catch (IOException e) { }
+ }
+ }
+ return addLibrary(jproject, newFile.getFullPath(), sourceAttachPath, sourceAttachRoot);
+ }
+
+ /**
+ * Creates and adds a class folder to the class path.
+ * @param jproject The parent project
+ * @param containerName
+ * @param sourceAttachPath The source attachment path
+ * @param sourceAttachRoot The source attachment root path
+ * @return The handle of the created root
+ * @throws CoreException
+ */
+ public static IPackageFragmentRoot addClassFolder(IJavaProject jproject, String containerName, IPath sourceAttachPath, IPath sourceAttachRoot) throws CoreException {
+ IProject project= jproject.getProject();
+ IContainer container= null;
+ if (containerName == null || containerName.length() == 0) {
+ container= project;
+ } else {
+ IFolder folder= project.getFolder(containerName);
+ if (!folder.exists()) {
+ CoreUtility.createFolder(folder, false, true, null);
+ }
+ container= folder;
+ }
+ IClasspathEntry cpe= JavaCore.newLibraryEntry(container.getFullPath(), sourceAttachPath, sourceAttachRoot);
+ addToClasspath(jproject, cpe);
+ return jproject.getPackageFragmentRoot(container);
+ }
+
+ /**
+ * Creates and adds a class folder to the class path and imports all files
+ * contained in the given ZIP file.
+ * @param jproject The parent project
+ * @param containerName
+ * @param sourceAttachPath The source attachment path
+ * @param sourceAttachRoot The source attachment root path
+ * @param zipFile
+ * @return The handle of the created root
+ * @throws IOException
+ * @throws CoreException
+ * @throws InvocationTargetException
+ */
+ public static IPackageFragmentRoot addClassFolderWithImport(IJavaProject jproject, String containerName, IPath sourceAttachPath, IPath sourceAttachRoot, File zipFile) throws IOException, CoreException, InvocationTargetException {
+ ZipFile file= new ZipFile(zipFile);
+ try {
+ IPackageFragmentRoot root= addClassFolder(jproject, containerName, sourceAttachPath, sourceAttachRoot);
+ importFilesFromZip(file, root.getPath(), null);
+ return root;
+ } finally {
+ file.close();
+ }
+ }
+
+ /**
+ * Adds a library entry pointing to a JRE (stubs only)
+ * and sets the right compiler options.
+ * <p>Currently, the compiler compliance level is 1.5.
+ *
+ * @param jproject target
+ * @return the new package fragment root
+ * @throws CoreException
+ */
+ public static IPackageFragmentRoot addRTJar(IJavaProject jproject) throws CoreException {
+ return addRTJar15(jproject);
+ }
+
+ public static IPackageFragmentRoot addRTJar13(IJavaProject jproject) throws CoreException {
+ IPath[] rtJarPath= findRtJar(RT_STUBS_13);
+
+ Map options= jproject.getOptions(false);
+ JavaProjectHelper.set13CompilerOptions(options);
+ jproject.setOptions(options);
+
+ return addLibrary(jproject, rtJarPath[0], rtJarPath[1], rtJarPath[2]);
+ }
+
+ public static IPackageFragmentRoot addRTJar15(IJavaProject jproject) throws CoreException, JavaModelException {
+ IPath[] rtJarPath= findRtJar(RT_STUBS_15);
+ set15CompilerOptions(jproject);
+ return addLibrary(jproject, rtJarPath[0], rtJarPath[1], rtJarPath[2]);
+ }
+
+ public static IPackageFragmentRoot addRTJar16(IJavaProject jproject) throws CoreException {
+ IPath[] rtJarPath= findRtJar(RT_STUBS_16);
+
+ Map options= jproject.getOptions(false);
+ JavaProjectHelper.set16CompilerOptions(options);
+ jproject.setOptions(options);
+
+ return addLibrary(jproject, rtJarPath[0], rtJarPath[1], rtJarPath[2]);
+ }
+
+ /**
+ * Adds a variable entry with source attachment to a IJavaProject.
+ * Can return null if variable can not be resolved.
+ * @param jproject The parent project
+ * @param path The variable path
+ * @param sourceAttachPath The source attachment path (variable path)
+ * @param sourceAttachRoot The source attachment root path (variable path)
+ * @return The added package fragment root
+ * @throws JavaModelException
+ */
+ public static IPackageFragmentRoot addVariableEntry(IJavaProject jproject, IPath path, IPath sourceAttachPath, IPath sourceAttachRoot) throws JavaModelException {
+ IClasspathEntry cpe= JavaCore.newVariableEntry(path, sourceAttachPath, sourceAttachRoot);
+ addToClasspath(jproject, cpe);
+ IPath resolvedPath= JavaCore.getResolvedVariablePath(path);
+ if (resolvedPath != null) {
+ return jproject.getPackageFragmentRoot(resolvedPath.toString());
+ }
+ return null;
+ }
+
+ public static IPackageFragmentRoot addVariableRTJar13(IJavaProject jproject, String libVarName, String srcVarName, String srcrootVarName) throws CoreException {
+ return addVariableRTJar(jproject, RT_STUBS_13, libVarName, srcVarName, srcrootVarName);
+ }
+
+ /**
+ * Adds a variable entry pointing to a current JRE (stubs only)
+ * and sets the compiler compliance level on the project accordingly.
+ * The arguments specify the names of the variables to be used.
+ * Currently, the compiler compliance level is set to 1.5.
+ *
+ * @param jproject the project to add the variable RT JAR
+ * @param libVarName Name of the variable for the library
+ * @param srcVarName Name of the variable for the source attachment. Can be <code>null</code>.
+ * @param srcrootVarName name of the variable for the source attachment root. Can be <code>null</code>.
+ * @return the new package fragment root
+ * @throws CoreException Creation failed
+ */
+ public static IPackageFragmentRoot addVariableRTJar(IJavaProject jproject, String libVarName, String srcVarName, String srcrootVarName) throws CoreException {
+ return addVariableRTJar(jproject, RT_STUBS_15, libVarName, srcVarName, srcrootVarName);
+ }
+
+ /**
+ * Adds a variable entry pointing to a current JRE (stubs only).
+ * The arguments specify the names of the variables to be used.
+ * Clients must not forget to set the right compiler compliance level on the project.
+ *
+ * @param jproject the project to add the variable RT JAR
+ * @param rtStubsPath path to an rt.jar
+ * @param libVarName name of the variable for the library
+ * @param srcVarName Name of the variable for the source attachment. Can be <code>null</code>.
+ * @param srcrootVarName Name of the variable for the source attachment root. Can be <code>null</code>.
+ * @return the new package fragment root
+ * @throws CoreException Creation failed
+ */
+ private static IPackageFragmentRoot addVariableRTJar(IJavaProject jproject, IPath rtStubsPath, String libVarName, String srcVarName, String srcrootVarName) throws CoreException {
+ IPath[] rtJarPaths= findRtJar(rtStubsPath);
+ IPath libVarPath= new Path(libVarName);
+ IPath srcVarPath= null;
+ IPath srcrootVarPath= null;
+ JavaCore.setClasspathVariable(libVarName, rtJarPaths[0], null);
+ if (srcVarName != null) {
+ IPath varValue= rtJarPaths[1] != null ? rtJarPaths[1] : Path.EMPTY;
+ JavaCore.setClasspathVariable(srcVarName, varValue, null);
+ srcVarPath= new Path(srcVarName);
+ }
+ if (srcrootVarName != null) {
+ IPath varValue= rtJarPaths[2] != null ? rtJarPaths[2] : Path.EMPTY;
+ JavaCore.setClasspathVariable(srcrootVarName, varValue, null);
+ srcrootVarPath= new Path(srcrootVarName);
+ }
+ return addVariableEntry(jproject, libVarPath, srcVarPath, srcrootVarPath);
+ }
+
+ /**
+ * Adds a required project entry.
+ * @param jproject Parent project
+ * @param required Project to add to the build path
+ * @throws JavaModelException Creation failed
+ */
+ public static void addRequiredProject(IJavaProject jproject, IJavaProject required) throws JavaModelException {
+ IClasspathEntry cpe= JavaCore.newProjectEntry(required.getProject().getFullPath());
+ addToClasspath(jproject, cpe);
+ }
+
+ public static void removeFromClasspath(IJavaProject jproject, IPath path) throws JavaModelException {
+ IClasspathEntry[] oldEntries= jproject.getRawClasspath();
+ int nEntries= oldEntries.length;
+ ArrayList list= new ArrayList(nEntries);
+ for (int i= 0 ; i < nEntries ; i++) {
+ IClasspathEntry curr= oldEntries[i];
+ if (!path.equals(curr.getPath())) {
+ list.add(curr);
+ }
+ }
+ IClasspathEntry[] newEntries= (IClasspathEntry[])list.toArray(new IClasspathEntry[list.size()]);
+ jproject.setRawClasspath(newEntries, null);
+ }
+
+ public static void addToClasspath(IJavaProject jproject, IClasspathEntry cpe) throws JavaModelException {
+ IClasspathEntry[] oldEntries= jproject.getRawClasspath();
+ for (int i= 0; i < oldEntries.length; i++) {
+ if (oldEntries[i].equals(cpe)) {
+ return;
+ }
+ }
+ int nEntries= oldEntries.length;
+ IClasspathEntry[] newEntries= new IClasspathEntry[nEntries + 1];
+ System.arraycopy(oldEntries, 0, newEntries, 0, nEntries);
+ newEntries[nEntries]= cpe;
+ jproject.setRawClasspath(newEntries, null);
+ }
+
+ /**
+ * @param rtStubsPath the path to the RT stubs
+ * @return a rt.jar (stubs only)
+ * @throws CoreException
+ */
+ public static IPath[] findRtJar(IPath rtStubsPath) throws CoreException {
+ File rtStubs= JavaTestPlugin.getDefault().getFileInPlugin(rtStubsPath);
+ Assert.assertNotNull(rtStubs);
+ Assert.assertTrue(rtStubs.exists());
+ return new IPath[] {
+ Path.fromOSString(rtStubs.getPath()),
+ null,
+ null
+ };
+ }
+
+//{ObjectTeams: expose to sub-classes
+/* orig:
+ private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
+ :giro */
+ protected static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
+// SH}
+ IProjectDescription description = proj.getDescription();
+ String[] prevNatures= description.getNatureIds();
+ String[] newNatures= new String[prevNatures.length + 1];
+ System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
+ newNatures[prevNatures.length]= natureId;
+ description.setNatureIds(newNatures);
+ proj.setDescription(description, monitor);
+ }
+
+ private static void importFilesFromZip(ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor) throws InvocationTargetException {
+ ZipFileStructureProvider structureProvider= new ZipFileStructureProvider(srcZipFile);
+ try {
+ ImportOperation op= new ImportOperation(destPath, structureProvider.getRoot(), structureProvider, new ImportOverwriteQuery());
+ op.run(monitor);
+ } catch (InterruptedException e) {
+ // should not happen
+ }
+ }
+
+ /**
+ * Imports resources from <code>bundleSourcePath</code> inside <code>bundle</code> into <code>importTarget</code>.
+ *
+ * @param importTarget the parent container
+ * @param bundle the bundle
+ * @param bundleSourcePath the path to a folder containing resources
+ *
+ * @throws CoreException import failed
+ * @throws IOException import failed
+ */
+ public static void importResources(IContainer importTarget, Bundle bundle, String bundleSourcePath) throws CoreException, IOException {
+ Enumeration entryPaths= bundle.getEntryPaths(bundleSourcePath);
+ while (entryPaths.hasMoreElements()) {
+ String path= (String) entryPaths.nextElement();
+//{ObjectTeams: don't let .svn dirs interfer with tests:
+ if (path.endsWith("/.svn/")) continue;
+// SH}
+ IPath name= new Path(path.substring(bundleSourcePath.length()));
+ if (path.endsWith("/")) {
+ IFolder folder= importTarget.getFolder(name);
+ folder.create(false, true, null);
+ importResources(folder, bundle, path);
+ } else {
+ URL url= bundle.getEntry(path);
+ IFile file= importTarget.getFile(name);
+ file.create(url.openStream(), true, null);
+ }
+ }
+ }
+
+ private static class ImportOverwriteQuery implements IOverwriteQuery {
+ public String queryOverwrite(String file) {
+ return ALL;
+ }
+ }
+
+ private static class Requestor extends TypeNameRequestor{
+ }
+
+ public static void emptyDisplayLoop() {
+ boolean showDebugInfo= false;
+
+ Display display= Display.getCurrent();
+ if (display != null) {
+ if (showDebugInfo) {
+ try {
+ Synchronizer synchronizer= display.getSynchronizer();
+ Field field= Synchronizer.class.getDeclaredField("messageCount");
+ field.setAccessible(true);
+ System.out.println("Processing " + field.getInt(synchronizer) + " messages in queue");
+ } catch (Exception e) {
+ // ignore
+ System.out.println(e);
+ }
+ }
+ while (display.readAndDispatch()) { /*loop*/ }
+ }
+ }
+}
+
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaTestPlugin.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaTestPlugin.java
new file mode 100644
index 000000000..f60f1b999
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaTestPlugin.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+
+public class JavaTestPlugin extends Plugin {
+
+ private static JavaTestPlugin fgDefault;
+
+ public JavaTestPlugin() {
+ fgDefault= this;
+ }
+
+ public static JavaTestPlugin getDefault() {
+ return fgDefault;
+ }
+
+ public static IWorkspace getWorkspace() {
+ return ResourcesPlugin.getWorkspace();
+ }
+
+ public File getFileInPlugin(IPath path) throws CoreException {
+ try {
+ URL installURL= new URL(getBundle().getEntry("/"), path.toString());
+ URL localURL= FileLocator.toFileURL(installURL);
+ return new File(localURL.getFile());
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, e.getMessage(), e));
+ }
+ }
+
+ public static String getPluginId() {
+ return "org.eclipse.jdt.ui.tests";
+ }
+
+ public static void log(IStatus status) {
+ getDefault().getLog().log(status);
+ }
+
+ public static void logErrorMessage(String message) {
+ log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, message, null));
+ }
+
+ public static void logErrorStatus(String message, IStatus status) {
+ if (status == null) {
+ logErrorMessage(message);
+ return;
+ }
+ MultiStatus multi= new MultiStatus(getPluginId(), IStatus.ERROR, message, null);
+ multi.add(status);
+ log(multi);
+ }
+
+ public static void log(Throwable e) {
+ log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, e.getMessage(), e));
+ }
+
+
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/MixedLineDelimiterDetector.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/MixedLineDelimiterDetector.java
new file mode 100644
index 000000000..1016f5806
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/MixedLineDelimiterDetector.java
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin;
+
+import junit.framework.Assert;
+
+import org.eclipse.core.resources.IResource;
+
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+
+
+/**
+ * Tests a resource or Java element and all its children
+ * for mixed line delimiters and throws an AFE in such a
+ * case.
+ *
+ * @since 3.1
+ */
+public class MixedLineDelimiterDetector {
+
+// private static final int MAC_LD= 0;
+// private static final int MIXED_LD= 1;
+// private static final int UNIX_LD= 2;
+// private static final int WINDOWS_LD= 3;
+//
+// private static class ResultCollector implements ITextSearchResultCollector {
+//
+// private List fResult;
+// private IProgressMonitor fProgressMonitor= new NullProgressMonitor();
+//
+// public ResultCollector(List result) {
+// fResult= result;
+// }
+//
+// public void aboutToStart() throws CoreException {
+// // do nothing;
+// }
+//
+// public void accept(IResourceProxy proxy, int start, int length) throws CoreException {
+// fResult.add(proxy.requestResource());
+// }
+//
+// public void done() throws CoreException {
+// // do nothing;
+// }
+//
+// public IProgressMonitor getProgressMonitor() {
+// return fProgressMonitor;
+// }
+// }
+//
+// private static class LineDelimiterLocator extends MatchLocator {
+//
+// protected static final int fgLF= '\n';
+// protected static final int fgCR= '\r';
+//
+// protected int fPushbackChar;
+// protected boolean fPushback;
+// private int fLineDelimiter= -1;
+//
+// public LineDelimiterLocator(int lineDelimiter) throws PatternSyntaxException {
+// super("", false, false); // hack - parameters are never used
+// fLineDelimiter= lineDelimiter;
+// }
+//
+// public boolean isEmpty() {
+// return false;
+// }
+//
+// private BufferedReader getBufferedReader(IFile file) throws CoreException, UnsupportedEncodingException {
+// return new BufferedReader(getReader(file));
+// }
+//
+// private Reader getReader(IFile file) throws UnsupportedEncodingException, CoreException{
+// return new InputStreamReader(file.getContents(false), ResourcesPlugin.getEncoding());
+// }
+//
+// protected int readLine(BufferedReader reader, StringBuffer sb) throws IOException {
+// int ch= -1;
+// if (fPushback) {
+// ch= fPushbackChar;
+// fPushback= false;
+// }
+// else
+// ch= reader.read();
+// while (ch != -1) {
+// if (ch == fgLF)
+// return UNIX_LD;
+// if (ch == fgCR) {
+// ch= reader.read();
+// if (ch == fgLF)
+// return WINDOWS_LD;
+//
+// fPushbackChar= ch;
+// fPushback= true;
+// return MAC_LD;
+// }
+// sb.append((char)ch);
+// ch= reader.read();
+// }
+// return -1;
+// }
+//
+// public void locateMatches(IProgressMonitor progressMonitor, CharSequence searchInput, ITextSearchResultCollector collector, IResourceProxy proxy) throws CoreException {
+// IFile file= (IFile)proxy.requestResource();
+// if (file.getContentDescription() == null || !FileBuffers.getTextFileBufferManager().isTextFileLocation(file.getFullPath(), true))
+// return;
+//
+// try {
+//
+// BufferedReader reader= getBufferedReader(file);
+// boolean eof= false;
+// int detectedLineDelimiter= -1;
+// fPushback= false;
+//
+// try {
+// while (!eof) {
+// StringBuffer sb= new StringBuffer(200);
+// int lineDelimiter= readLine(reader, sb);
+//
+// eof= (lineDelimiter == -1);
+//
+// if (detectedLineDelimiter == -1)
+// detectedLineDelimiter= lineDelimiter;
+//
+// if (!eof && lineDelimiter != detectedLineDelimiter) {
+// detectedLineDelimiter= MIXED_LD;
+// break;
+// }
+//
+// if (progressMonitor.isCanceled())
+// throw new OperationCanceledException(SearchMessages.TextSearchVisitor_canceled);
+// }
+// if (fLineDelimiter == detectedLineDelimiter)
+// collector.accept(proxy, 0, 0);
+// } finally {
+// if (reader != null)
+// reader.close();
+// }
+// } catch (IOException e) {
+// String[] args= { e.toString(), file.getFullPath().makeRelative().toString()};
+// String message= Messages.format(SearchMessages.TextSearchVisitor_error, args);
+// throw new CoreException(new Status(IStatus.ERROR, NewSearchUI.PLUGIN_ID, Platform.PLUGIN_ERROR, message, e));
+// } finally {
+// }
+// }
+// }
+
+ public static void assertNoMixedLineDelimiters(IJavaElement elem) {
+ IResource resource;
+ if (elem instanceof IJavaProject)
+ resource= ((IJavaProject)elem).getProject();
+ else
+ resource= elem.getResource();
+
+ assertNoMixedLineDelimiters(resource);
+ }
+ public static void assertNoMixedLineDelimiters(IResource resource) {
+ IResource[] mixedResources= findFilesWithMixedLineDelimiters(resource);
+ Assert.assertTrue(mixedResources == null || mixedResources.length == 0);
+ }
+
+ /**
+ * Finds files with mixed line delimiters.
+ *
+ * @param resource the resource to search
+ * @return the resources with mixed line delimiters
+ */
+ private static IResource[] findFilesWithMixedLineDelimiters(final IResource resource) {
+// final List result= new ArrayList(5);
+// ResultCollector collector= new ResultCollector(result);
+// TextSearchEngine engine= new TextSearchEngine();
+// SearchScope scope= SearchScope.newSearchScope("", new IResource[] { resource }); //$NON-NLS-1$
+// engine.search(scope, false, collector, new LineDelimiterLocator(MIXED_LD));
+// return (IResource[])result.toArray(new IResource[result.size()]);
+
+ Assert.fail("support currently disabled");
+
+ return new IResource[0];
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/OrderedTestSuite.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/OrderedTestSuite.java
new file mode 100644
index 000000000..65fe7b356
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/OrderedTestSuite.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin;
+
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+/**
+ * Test suite with user-specified test order.
+ * Fails if not all test methods are listed.
+ */
+public class OrderedTestSuite extends TestSuite {
+
+ public OrderedTestSuite(final Class testClass, String[] testMethods) {
+ super(testClass.getName());
+
+ Set existingMethods= new HashSet();
+ Method[] methods= testClass.getMethods(); // just public member methods
+ for (int i= 0; i < methods.length; i++) {
+ Method method= methods[i];
+ existingMethods.add(method.getName());
+ }
+
+ for (int i= 0; i < testMethods.length; i++) {
+ final String testMethod= testMethods[i];
+ if (existingMethods.remove(testMethod)) {
+ addTest(createTest(testClass, testMethod));
+ } else {
+ addTest(error(testMethod, new IllegalArgumentException(
+ "Class '" + testClass.getName() + " misses test method '" + testMethod
+ + "'.")));
+ }
+ }
+
+ for (Iterator iter= existingMethods.iterator(); iter.hasNext();) {
+ String existingMethod= (String) iter.next();
+ if (existingMethod.startsWith("test")) {
+ addTest(error(existingMethod, new IllegalArgumentException(
+ "Test method '" + existingMethod + "' not listed in OrderedTestSuite of class '"
+ + testClass.getName() + "'.")));
+ }
+ }
+
+ }
+
+ public static Test error(String testMethod, Exception exception) {
+ final Throwable e2= exception.fillInStackTrace();
+ return new TestCase(testMethod) {
+ protected void runTest() throws Throwable {
+ throw e2;
+ }
+ };
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/StringAsserts.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/StringAsserts.java
new file mode 100644
index 000000000..c0e2b7de6
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/StringAsserts.java
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import junit.framework.Assert;
+
+/**
+ *
+ */
+public class StringAsserts {
+ /**
+ *
+ */
+ public StringAsserts() {
+ super();
+ }
+
+ private static int getDiffPos(String str1, String str2) {
+ int len1= Math.min(str1.length(), str2.length());
+
+ int diffPos= -1;
+ for (int i= 0; i < len1; i++) {
+ if (str1.charAt(i) != str2.charAt(i)) {
+ diffPos= i;
+ break;
+ }
+ }
+ if (diffPos == -1 && str1.length() != str2.length()) {
+ diffPos= len1;
+ }
+ return diffPos;
+ }
+
+ private static final int printRange= 6;
+
+ public static void assertEqualString(String actual, String expected) {
+ if (actual == null || expected == null) {
+ if (actual == expected) {
+ return;
+ }
+ if (actual == null) {
+ Assert.assertTrue("Content not as expected: is 'null' expected: " + expected, false);
+ } else {
+ Assert.assertTrue("Content not as expected: expected 'null' is: " + actual, false);
+ }
+ }
+
+ int diffPos= getDiffPos(actual, expected);
+ if (diffPos != -1) {
+ int diffAhead= Math.max(0, diffPos - printRange);
+ int diffAfter= Math.min(actual.length(), diffPos + printRange);
+
+ String diffStr= actual.substring(diffAhead, diffPos) + '^' + actual.substring(diffPos, diffAfter);
+
+ // use detailed message
+ String message= "Content not as expected: is\n" + actual + "\nDiffers at pos " + diffPos + ": " + diffStr + "\nexpected:\n" + expected; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ Assert.assertEquals(message, expected, actual);
+ }
+ }
+
+ public static void assertEqualStringIgnoreDelim(String actual, String expected) throws IOException {
+ if (actual == null || expected == null) {
+ if (actual == expected) {
+ return;
+ }
+ if (actual == null) {
+ Assert.assertTrue("Content not as expected: is 'null' expected: " + expected, false);
+ } else {
+ Assert.assertTrue("Content not as expected: expected 'null' is: " + actual, false);
+ }
+ }
+
+ BufferedReader read1= new BufferedReader(new StringReader(actual));
+ BufferedReader read2= new BufferedReader(new StringReader(expected));
+
+ int line= 1;
+ do {
+ String s1= read1.readLine();
+ String s2= read2.readLine();
+
+ if (s1 == null || !s1.equals(s2)) {
+ if (s1 == null && s2 == null) {
+ return;
+ }
+ String diffStr= (s1 == null) ? s2 : s1;
+
+ String message= "Content not as expected: Content is: \n" + actual + "\nDiffers at line " + line + ": " + diffStr + "\nExpected contents: \n" + expected;
+ Assert.assertEquals(message, expected, actual);
+ }
+ line++;
+ } while (true);
+ }
+
+ public static void assertEqualStringsIgnoreOrder(String[] actuals, String[] expecteds) {
+ ArrayList list1= new ArrayList(Arrays.asList(actuals));
+ ArrayList list2= new ArrayList(Arrays.asList(expecteds));
+
+ for (int i= list1.size() - 1; i >= 0; i--) {
+ if (list2.remove(list1.get(i))) {
+ list1.remove(i);
+ }
+ }
+
+ int n1= list1.size();
+ int n2= list2.size();
+
+ if (n1 + n2 > 0) {
+ if (n1 == 1 && n2 == 1) {
+ assertEqualString((String) list1.get(0), (String) list2.get(0));
+ }
+
+ StringBuffer buf= new StringBuffer();
+ for (int i= 0; i < n1; i++) {
+ String s1= (String) list1.get(i);
+ if (s1 != null) {
+ buf.append(s1);
+ buf.append("\n");
+ }
+ }
+ String actual= buf.toString();
+
+ buf= new StringBuffer();
+ for (int i= 0; i < n2; i++) {
+ String s2= (String) list2.get(i);
+ if (s2 != null) {
+ buf.append(s2);
+ buf.append("\n");
+ }
+ }
+ String expected= buf.toString();
+
+ String message= "Content not as expected: Content is: \n" + actual + "\nExpected contents: \n" + expected;
+ Assert.assertEquals(message, expected, actual);
+ }
+ }
+
+ public static void assertExpectedExistInProposals(String[] actuals, String[] expecteds) {
+ ArrayList list1= new ArrayList(Arrays.asList(actuals));
+ ArrayList list2= new ArrayList(Arrays.asList(expecteds));
+
+ for (int i= list1.size() - 1; i >= 0; i--) {
+ if (list2.remove(list1.get(i))) {
+ list1.remove(i);
+ }
+ }
+
+ int n1= list1.size();
+ int n2= list2.size();
+
+ if (n2 > 0) {
+ if (n1 == 1 && n2 == 1) {
+ assertEqualString((String) list1.get(0), (String) list2.get(0));
+ }
+
+ StringBuffer buf= new StringBuffer();
+ for (int i= 0; i < n1; i++) {
+ String s1= (String) list1.get(i);
+ if (s1 != null) {
+ buf.append(s1);
+ buf.append("\n");
+ }
+ }
+ String actual= buf.toString();
+
+ buf= new StringBuffer();
+ for (int i= 0; i < n2; i++) {
+ String s2= (String) list2.get(i);
+ if (s2 != null) {
+ buf.append(s2);
+ buf.append("\n");
+ }
+ }
+ String expected= buf.toString();
+
+ String message= "Content not as expected: Content is: \n" + actual + "\nExpected contents: \n" + expected;
+ Assert.assertEquals(message, expected, actual);
+ }
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java
new file mode 100644
index 000000000..f092a7677
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java
@@ -0,0 +1,633 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin;
+
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
+
+import org.eclipse.jdt.internal.formatter.align.Alignment;
+
+import org.eclipse.jdt.ui.PreferenceConstants;
+
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+
+public class TestOptions {
+
+ public static Hashtable getDefaultOptions() {
+ Hashtable result= JavaCore.getDefaultOptions();
+ result.put(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING, JavaCore.IGNORE);
+ result.put(JavaCore.COMPILER_PB_FIELD_HIDING, JavaCore.IGNORE);
+ result.put(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaCore.IGNORE);
+ result.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.IGNORE);
+ result.put(JavaCore.COMPILER_PB_RAW_TYPE_REFERENCE, JavaCore.IGNORE);
+ result.put(JavaCore.COMPILER_PB_UNUSED_WARNING_TOKEN, JavaCore.IGNORE);
+ result.put(JavaCore.COMPILER_PB_DEAD_CODE, JavaCore.IGNORE);
+ // should cover all compiler settings
+ result.putAll(TestFormatterOptions.getSettings());
+ return result;
+ }
+
+ public static void initializeCodeGenerationOptions() {
+ IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
+ store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, false);
+ store.setValue(PreferenceConstants.CODEGEN_IS_FOR_GETTERS, true);
+ store.setValue(PreferenceConstants.CODEGEN_EXCEPTION_VAR_NAME, "e"); //$NON-NLS-1$
+ store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, true);
+ store.setValue(PreferenceConstants.ORGIMPORTS_IMPORTORDER, "java;javax;org;com"); //$NON-NLS-1$
+ store.setValue(PreferenceConstants.ORGIMPORTS_ONDEMANDTHRESHOLD, 99);
+ store.setValue(PreferenceConstants.ORGIMPORTS_IGNORELOWERCASE, true);
+ }
+
+ public static void initializeProjectOptions(IJavaProject project) {
+ Map options= new HashMap();
+ JavaProjectHelper.set15CompilerOptions(options);
+ project.setOptions(options);
+ }
+
+}
+
+class TestFormatterOptions {
+
+ public static Hashtable getSettings() {
+ TestFormatterOptions options = new TestFormatterOptions();
+ options.setDefaultSettings();
+ return options.getMap();
+ }
+
+ public int alignment_for_arguments_in_allocation_expression;
+ public int alignment_for_arguments_in_explicit_constructor_call;
+ public int alignment_for_arguments_in_method_invocation;
+ public int alignment_for_arguments_in_qualified_allocation_expression;
+ public int alignment_for_binary_expression;
+ public int alignment_for_compact_if;
+ public int alignment_for_conditional_expression;
+ public int alignment_for_expressions_in_array_initializer;
+ public int alignment_for_multiple_fields;
+ public int alignment_for_parameters_in_constructor_declaration;
+ public int alignment_for_parameters_in_method_declaration;
+ public int alignment_for_selector_in_method_invocation;
+ public int alignment_for_superclass_in_type_declaration;
+ public int alignment_for_superinterfaces_in_type_declaration;
+ public int alignment_for_throws_clause_in_constructor_declaration;
+ public int alignment_for_throws_clause_in_method_declaration;
+
+ public boolean align_type_members_on_columns;
+
+ public String brace_position_for_anonymous_type_declaration;
+ public String brace_position_for_array_initializer;
+ public String brace_position_for_block;
+ public String brace_position_for_block_in_case;
+ public String brace_position_for_constructor_declaration;
+ public String brace_position_for_method_declaration;
+ public String brace_position_for_type_declaration;
+ public String brace_position_for_switch;
+
+ public int continuation_indentation;
+ public int continuation_indentation_for_array_initializer;
+
+ public int blank_lines_after_imports;
+ public int blank_lines_after_package;
+ public int blank_lines_before_field;
+ public int blank_lines_before_first_class_body_declaration;
+ public int blank_lines_before_imports;
+ public int blank_lines_before_member_type;
+ public int blank_lines_before_method;
+ public int blank_lines_before_new_chunk;
+ public int blank_lines_before_package;
+ public int blank_lines_between_type_declarations;
+ public int blank_lines_at_beginning_of_method_body;
+
+ public boolean indent_statements_compare_to_block;
+ public boolean indent_statements_compare_to_body;
+ public boolean indent_body_declarations_compare_to_type_header;
+ public boolean indent_breaks_compare_to_cases;
+ public boolean indent_switchstatements_compare_to_cases;
+ public boolean indent_switchstatements_compare_to_switch;
+
+ public boolean insert_new_line_after_opening_brace_in_array_initializer;
+ public boolean insert_new_line_after_annotation_on_member;
+ public boolean insert_new_line_after_annotation_on_parameter;
+ public boolean insert_new_line_after_annotation_on_local_variable;
+ public boolean insert_new_line_at_end_of_file_if_missing;
+ public boolean insert_new_line_before_catch_in_try_statement;
+ public boolean insert_new_line_before_closing_brace_in_array_initializer;
+ public boolean insert_new_line_before_else_in_if_statement;
+ public boolean insert_new_line_before_finally_in_try_statement;
+ public boolean insert_new_line_before_while_in_do_statement;
+ public boolean insert_new_line_in_empty_anonymous_type_declaration;
+ public boolean insert_new_line_in_empty_block;
+ public boolean insert_new_line_in_empty_method_body;
+ public boolean insert_new_line_in_empty_type_declaration;
+ public boolean insert_space_after_assignment_operator;
+ public boolean insert_space_after_binary_operator;
+ public boolean insert_space_after_closing_paren_in_cast;
+ public boolean insert_space_after_closing_brace_in_block;
+ public boolean insert_space_after_colon_in_assert;
+ public boolean insert_space_after_colon_in_case;
+ public boolean insert_space_after_colon_in_conditional;
+ public boolean insert_space_after_colon_in_labeled_statement;
+ public boolean insert_space_after_comma_in_allocation_expression;
+ public boolean insert_space_after_comma_in_array_initializer;
+ public boolean insert_space_after_comma_in_constructor_declaration_parameters;
+ public boolean insert_space_after_comma_in_constructor_declaration_throws;
+ public boolean insert_space_after_comma_in_explicit_constructor_call_arguments;
+ public boolean insert_space_after_comma_in_for_increments;
+ public boolean insert_space_after_comma_in_for_inits;
+ public boolean insert_space_after_comma_in_method_invocation_arguments;
+ public boolean insert_space_after_comma_in_method_declaration_parameters;
+ public boolean insert_space_after_comma_in_method_declaration_throws;
+ public boolean insert_space_after_comma_in_multiple_field_declarations;
+ public boolean insert_space_after_comma_in_multiple_local_declarations;
+ public boolean insert_space_after_comma_in_superinterfaces;
+ public boolean insert_space_after_opening_bracket_in_array_allocation_expression;
+ public boolean insert_space_after_opening_bracket_in_array_reference;
+ public boolean insert_space_after_opening_brace_in_array_initializer;
+ public boolean insert_space_after_opening_paren_in_cast;
+ public boolean insert_space_after_opening_paren_in_catch;
+ public boolean insert_space_after_opening_paren_in_constructor_declaration;
+ public boolean insert_space_after_opening_paren_in_for;
+ public boolean insert_space_after_opening_paren_in_if;
+ public boolean insert_space_after_opening_paren_in_method_declaration;
+ public boolean insert_space_after_opening_paren_in_method_invocation;
+ public boolean insert_space_after_opening_paren_in_parenthesized_expression;
+ public boolean insert_space_after_opening_paren_in_switch;
+ public boolean insert_space_after_opening_paren_in_synchronized;
+ public boolean insert_space_after_opening_paren_in_while;
+ public boolean insert_space_after_postfix_operator;
+ public boolean insert_space_after_prefix_operator;
+ public boolean insert_space_after_question_in_conditional;
+ public boolean insert_space_after_semicolon_in_for;
+ public boolean insert_space_after_unary_operator;
+ public boolean insert_space_before_assignment_operator;
+ public boolean insert_space_before_binary_operator;
+ public boolean insert_space_before_closing_brace_in_array_initializer;
+ public boolean insert_space_before_closing_bracket_in_array_allocation_expression;
+ public boolean insert_space_before_closing_bracket_in_array_reference;
+ public boolean insert_space_before_closing_paren_in_cast;
+ public boolean insert_space_before_closing_paren_in_catch;
+ public boolean insert_space_before_closing_paren_in_constructor_declaration;
+ public boolean insert_space_before_closing_paren_in_for;
+ public boolean insert_space_before_closing_paren_in_if;
+ public boolean insert_space_before_closing_paren_in_method_declaration;
+ public boolean insert_space_before_closing_paren_in_method_invocation;
+ public boolean insert_space_before_closing_paren_in_parenthesized_expression;
+ public boolean insert_space_before_closing_paren_in_switch;
+ public boolean insert_space_before_closing_paren_in_synchronized;
+ public boolean insert_space_before_closing_paren_in_while;
+ public boolean insert_space_before_colon_in_assert;
+ public boolean insert_space_before_colon_in_case;
+ public boolean insert_space_before_colon_in_conditional;
+ public boolean insert_space_before_colon_in_default;
+ public boolean insert_space_before_colon_in_labeled_statement;
+ public boolean insert_space_before_comma_in_allocation_expression;
+ public boolean insert_space_before_comma_in_array_initializer;
+ public boolean insert_space_before_comma_in_constructor_declaration_parameters;
+ public boolean insert_space_before_comma_in_constructor_declaration_throws;
+ public boolean insert_space_before_comma_in_explicit_constructor_call_arguments;
+ public boolean insert_space_before_comma_in_for_increments;
+ public boolean insert_space_before_comma_in_for_inits;
+ public boolean insert_space_before_comma_in_method_invocation_arguments;
+ public boolean insert_space_before_comma_in_method_declaration_parameters;
+ public boolean insert_space_before_comma_in_method_declaration_throws;
+ public boolean insert_space_before_comma_in_multiple_field_declarations;
+ public boolean insert_space_before_comma_in_multiple_local_declarations;
+ public boolean insert_space_before_comma_in_superinterfaces;
+ public boolean insert_space_before_opening_brace_in_anonymous_type_declaration;
+ public boolean insert_space_before_opening_brace_in_array_initializer;
+ public boolean insert_space_before_opening_brace_in_block;
+ public boolean insert_space_before_opening_brace_in_constructor_declaration;
+ public boolean insert_space_before_opening_brace_in_method_declaration;
+ public boolean insert_space_before_opening_brace_in_type_declaration;
+ public boolean insert_space_before_opening_bracket_in_array_allocation_expression;
+ public boolean insert_space_before_opening_bracket_in_array_reference;
+ public boolean insert_space_before_opening_bracket_in_array_type_reference;
+ public boolean insert_space_before_opening_paren_in_catch;
+ public boolean insert_space_before_opening_paren_in_constructor_declaration;
+ public boolean insert_space_before_opening_paren_in_for;
+ public boolean insert_space_before_opening_paren_in_if;
+ public boolean insert_space_before_opening_paren_in_method_invocation;
+ public boolean insert_space_before_opening_paren_in_method_declaration;
+ public boolean insert_space_before_opening_paren_in_switch;
+ public boolean insert_space_before_opening_brace_in_switch;
+ public boolean insert_space_before_opening_paren_in_synchronized;
+ public boolean insert_space_before_opening_paren_in_parenthesized_expression;
+ public boolean insert_space_before_opening_paren_in_while;
+ public boolean insert_space_before_postfix_operator;
+ public boolean insert_space_before_prefix_operator;
+ public boolean insert_space_before_question_in_conditional;
+ public boolean insert_space_before_semicolon;
+ public boolean insert_space_before_semicolon_in_for;
+ public boolean insert_space_before_unary_operator;
+ public boolean insert_space_between_brackets_in_array_type_reference;
+ public boolean insert_space_between_empty_braces_in_array_initializer;
+ public boolean insert_space_between_empty_brackets_in_array_allocation_expression;
+ public boolean insert_space_between_empty_parens_in_constructor_declaration;
+ public boolean insert_space_between_empty_parens_in_method_declaration;
+ public boolean insert_space_between_empty_parens_in_method_invocation;
+ public boolean compact_else_if;
+ public boolean keep_guardian_clause_on_one_line;
+ public boolean keep_else_statement_on_same_line;
+ public boolean keep_empty_array_initializer_on_one_line;
+ public boolean keep_simple_if_on_one_line;
+ public boolean keep_then_statement_on_same_line;
+ public boolean never_indent_block_comments_on_first_column;
+ public boolean never_indent_line_comments_on_first_column;
+ public int number_of_empty_lines_to_preserve;
+ public boolean put_empty_statement_on_new_line;
+ public int tab_size;
+ public final char filling_space = ' ';
+ public int page_width;
+ public boolean use_tab;
+ public boolean wrapBeforeBinaryOperator;
+
+ public int initial_indentation_level;
+ public String line_separator;
+
+ private TestFormatterOptions() {
+ // cannot be instantiated
+ }
+
+ private String getAlignment(int alignment) {
+ return Integer.toString(alignment);
+ }
+
+ private Hashtable getMap() {
+ Hashtable options = new Hashtable();
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION, getAlignment(this.alignment_for_arguments_in_allocation_expression));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL, getAlignment(this.alignment_for_arguments_in_explicit_constructor_call));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, getAlignment(this.alignment_for_arguments_in_method_invocation));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION, getAlignment(this.alignment_for_arguments_in_qualified_allocation_expression));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION, getAlignment(this.alignment_for_binary_expression));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF, getAlignment(this.alignment_for_compact_if));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, getAlignment(this.alignment_for_conditional_expression));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, getAlignment(this.alignment_for_expressions_in_array_initializer));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS, getAlignment(this.alignment_for_multiple_fields));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, getAlignment(this.alignment_for_parameters_in_constructor_declaration));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, getAlignment(this.alignment_for_parameters_in_method_declaration));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION, getAlignment(this.alignment_for_selector_in_method_invocation));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION, getAlignment(this.alignment_for_superclass_in_type_declaration));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION, getAlignment(this.alignment_for_superinterfaces_in_type_declaration));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION, getAlignment(this.alignment_for_throws_clause_in_constructor_declaration));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION, getAlignment(this.alignment_for_throws_clause_in_method_declaration));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS, this.align_type_members_on_columns ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, this.brace_position_for_anonymous_type_declaration);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, this.brace_position_for_array_initializer);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, this.brace_position_for_block);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE, this.brace_position_for_block_in_case);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, this.brace_position_for_constructor_declaration);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, this.brace_position_for_method_declaration);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, this.brace_position_for_type_declaration);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, this.brace_position_for_switch);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, Integer.toString(this.continuation_indentation));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, Integer.toString(this.continuation_indentation_for_array_initializer));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_IMPORTS, Integer.toString(this.blank_lines_after_imports));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_PACKAGE, Integer.toString(this.blank_lines_after_package));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIELD, Integer.toString(this.blank_lines_before_field));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION, Integer.toString(this.blank_lines_before_first_class_body_declaration));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_IMPORTS, Integer.toString(this.blank_lines_before_imports));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_MEMBER_TYPE, Integer.toString(this.blank_lines_before_member_type));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD, Integer.toString(this.blank_lines_before_method));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_NEW_CHUNK, Integer.toString(this.blank_lines_before_new_chunk));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_PACKAGE, Integer.toString(this.blank_lines_before_package));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_TYPE_DECLARATIONS, Integer.toString(this.blank_lines_between_type_declarations));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY, Integer.toString(this.blank_lines_at_beginning_of_method_body));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK, this.indent_statements_compare_to_block ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY, this.indent_statements_compare_to_body ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER, this.indent_body_declarations_compare_to_type_header ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES, this.indent_breaks_compare_to_cases ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES, this.indent_switchstatements_compare_to_cases ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH, this.indent_switchstatements_compare_to_switch ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, this.insert_new_line_after_opening_brace_in_array_initializer? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER, this.insert_new_line_after_annotation_on_member? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, this.insert_new_line_after_annotation_on_parameter? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, this.insert_new_line_after_annotation_on_local_variable? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, this.insert_new_line_at_end_of_file_if_missing? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, this.insert_new_line_before_catch_in_try_statement? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, this.insert_new_line_before_closing_brace_in_array_initializer? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, this.insert_new_line_before_else_in_if_statement? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, this.insert_new_line_before_finally_in_try_statement? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, this.insert_new_line_before_while_in_do_statement? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION, this.insert_new_line_in_empty_anonymous_type_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK, this.insert_new_line_in_empty_block? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY, this.insert_new_line_in_empty_method_body? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION, this.insert_new_line_in_empty_type_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, this.insert_space_after_assignment_operator? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, this.insert_space_after_binary_operator? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, this.insert_space_after_closing_paren_in_cast? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, this.insert_space_after_closing_brace_in_block? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_ASSERT, this.insert_space_after_colon_in_assert? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CASE, this.insert_space_after_colon_in_case? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL, this.insert_space_after_colon_in_conditional? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, this.insert_space_after_colon_in_labeled_statement? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION, this.insert_space_after_comma_in_allocation_expression? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, this.insert_space_after_comma_in_array_initializer? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS, this.insert_space_after_comma_in_constructor_declaration_parameters? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS, this.insert_space_after_comma_in_constructor_declaration_throws? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS, this.insert_space_after_comma_in_explicit_constructor_call_arguments? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS, this.insert_space_after_comma_in_for_increments? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, this.insert_space_after_comma_in_for_inits? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, this.insert_space_after_comma_in_method_invocation_arguments? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS, this.insert_space_after_comma_in_method_declaration_parameters? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS, this.insert_space_after_comma_in_method_declaration_throws? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS, this.insert_space_after_comma_in_multiple_field_declarations? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS, this.insert_space_after_comma_in_multiple_local_declarations? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES, this.insert_space_after_comma_in_superinterfaces? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, this.insert_space_after_opening_bracket_in_array_allocation_expression? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_REFERENCE, this.insert_space_after_opening_bracket_in_array_reference? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, this.insert_space_after_opening_brace_in_array_initializer? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, this.insert_space_after_opening_paren_in_cast? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, this.insert_space_after_opening_paren_in_catch? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, this.insert_space_after_opening_paren_in_constructor_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, this.insert_space_after_opening_paren_in_for? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, this.insert_space_after_opening_paren_in_if? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, this.insert_space_after_opening_paren_in_method_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, this.insert_space_after_opening_paren_in_method_invocation? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, this.insert_space_after_opening_paren_in_parenthesized_expression? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH, this.insert_space_after_opening_paren_in_switch? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED, this.insert_space_after_opening_paren_in_synchronized? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE, this.insert_space_after_opening_paren_in_while? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, this.insert_space_after_postfix_operator? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, this.insert_space_after_prefix_operator? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL, this.insert_space_after_question_in_conditional? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, this.insert_space_after_semicolon_in_for? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR, this.insert_space_after_unary_operator? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, this.insert_space_before_assignment_operator? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, this.insert_space_before_binary_operator? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, this.insert_space_before_closing_brace_in_array_initializer? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, this.insert_space_before_closing_bracket_in_array_allocation_expression? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_REFERENCE, this.insert_space_before_closing_bracket_in_array_reference? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST, this.insert_space_before_closing_paren_in_cast? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, this.insert_space_before_closing_paren_in_catch? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION, this.insert_space_before_closing_paren_in_constructor_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, this.insert_space_before_closing_paren_in_for? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF, this.insert_space_before_closing_paren_in_if? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION, this.insert_space_before_closing_paren_in_method_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, this.insert_space_before_closing_paren_in_method_invocation? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, this.insert_space_before_closing_paren_in_parenthesized_expression? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH, this.insert_space_before_closing_paren_in_switch? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SYNCHRONIZED, this.insert_space_before_closing_paren_in_synchronized? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE, this.insert_space_before_closing_paren_in_while? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_ASSERT, this.insert_space_before_colon_in_assert? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE, this.insert_space_before_colon_in_case? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL, this.insert_space_before_colon_in_conditional? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT, this.insert_space_before_colon_in_default? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, this.insert_space_before_colon_in_labeled_statement? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION, this.insert_space_before_comma_in_allocation_expression? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ARRAY_INITIALIZER, this.insert_space_before_comma_in_array_initializer? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS, this.insert_space_before_comma_in_constructor_declaration_parameters? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS, this.insert_space_before_comma_in_constructor_declaration_throws? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS, this.insert_space_before_comma_in_explicit_constructor_call_arguments? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS, this.insert_space_before_comma_in_for_increments? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, this.insert_space_before_comma_in_for_inits? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, this.insert_space_before_comma_in_method_invocation_arguments? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS, this.insert_space_before_comma_in_method_declaration_parameters? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS, this.insert_space_before_comma_in_method_declaration_throws? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS, this.insert_space_before_comma_in_multiple_field_declarations? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS, this.insert_space_before_comma_in_multiple_local_declarations? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES, this.insert_space_before_comma_in_superinterfaces? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANONYMOUS_TYPE_DECLARATION, this.insert_space_before_opening_brace_in_anonymous_type_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, this.insert_space_before_opening_brace_in_array_initializer? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK, this.insert_space_before_opening_brace_in_block? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_CONSTRUCTOR_DECLARATION, this.insert_space_before_opening_brace_in_constructor_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION, this.insert_space_before_opening_brace_in_method_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION, this.insert_space_before_opening_brace_in_type_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, this.insert_space_before_opening_bracket_in_array_allocation_expression ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_REFERENCE, this.insert_space_before_opening_bracket_in_array_reference? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_TYPE_REFERENCE, this.insert_space_before_opening_bracket_in_array_type_reference? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, this.insert_space_before_opening_paren_in_catch? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, this.insert_space_before_opening_paren_in_constructor_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, this.insert_space_before_opening_paren_in_for? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, this.insert_space_before_opening_paren_in_if? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, this.insert_space_before_opening_paren_in_method_invocation? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, this.insert_space_before_opening_paren_in_method_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH, this.insert_space_before_opening_paren_in_switch? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH, this.insert_space_before_opening_brace_in_switch? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED, this.insert_space_before_opening_paren_in_synchronized? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, this.insert_space_before_opening_paren_in_parenthesized_expression? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, this.insert_space_before_opening_paren_in_while? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, this.insert_space_before_postfix_operator? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR, this.insert_space_before_prefix_operator? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, this.insert_space_before_question_in_conditional? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, this.insert_space_before_semicolon? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR, this.insert_space_before_semicolon_in_for? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR, this.insert_space_before_unary_operator? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_TYPE_REFERENCE, this.insert_space_between_brackets_in_array_type_reference? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, this.insert_space_between_empty_braces_in_array_initializer? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS_IN_ARRAY_ALLOCATION_EXPRESSION, this.insert_space_between_empty_brackets_in_array_allocation_expression? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION, this.insert_space_between_empty_parens_in_constructor_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, this.insert_space_between_empty_parens_in_method_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, this.insert_space_between_empty_parens_in_method_invocation? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_COMPACT_ELSE_IF, this.compact_else_if ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE, this.keep_guardian_clause_on_one_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_ELSE_STATEMENT_ON_SAME_LINE, this.keep_else_statement_on_same_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, this.keep_empty_array_initializer_on_one_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_SIMPLE_IF_ON_ONE_LINE, this.keep_simple_if_on_one_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_THEN_STATEMENT_ON_SAME_LINE, this.keep_then_statement_on_same_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, Integer.toString(this.number_of_empty_lines_to_preserve));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, this.put_empty_statement_on_new_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, Integer.toString(this.page_width));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, this.use_tab ? JavaCore.TAB: JavaCore.SPACE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, Integer.toString(this.tab_size));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_WRAP_BEFORE_BINARY_OPERATOR, this.wrapBeforeBinaryOperator ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN, this.never_indent_block_comments_on_first_column ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, this.never_indent_line_comments_on_first_column ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ return options;
+ }
+
+ private void setDefaultSettings() {
+ this.alignment_for_arguments_in_allocation_expression = Alignment.M_COMPACT_SPLIT;
+ this.alignment_for_arguments_in_explicit_constructor_call = Alignment.M_COMPACT_SPLIT;
+ this.alignment_for_arguments_in_method_invocation = Alignment.M_COMPACT_SPLIT;
+ this.alignment_for_arguments_in_qualified_allocation_expression = Alignment.M_COMPACT_SPLIT;
+ this.alignment_for_binary_expression = Alignment.M_COMPACT_SPLIT;
+ this.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_INDENT_BY_ONE;
+ this.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT;
+ this.alignment_for_expressions_in_array_initializer = Alignment.M_COMPACT_SPLIT;
+ this.alignment_for_multiple_fields = Alignment.M_COMPACT_SPLIT;
+ this.alignment_for_parameters_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
+ this.alignment_for_parameters_in_method_declaration = Alignment.M_COMPACT_SPLIT;
+ this.alignment_for_selector_in_method_invocation = Alignment.M_COMPACT_SPLIT;
+ this.alignment_for_superclass_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
+ this.alignment_for_superinterfaces_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
+ this.alignment_for_throws_clause_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
+ this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT;
+ this.align_type_members_on_columns = false;
+ this.brace_position_for_anonymous_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
+ this.brace_position_for_array_initializer = DefaultCodeFormatterConstants.END_OF_LINE;
+ this.brace_position_for_block = DefaultCodeFormatterConstants.END_OF_LINE;
+ this.brace_position_for_block_in_case = DefaultCodeFormatterConstants.END_OF_LINE;
+ this.brace_position_for_constructor_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
+ this.brace_position_for_method_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
+ this.brace_position_for_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
+ this.brace_position_for_switch = DefaultCodeFormatterConstants.END_OF_LINE;
+ this.continuation_indentation = 2;
+ this.continuation_indentation_for_array_initializer = 2;
+ this.blank_lines_after_imports = 0;
+ this.blank_lines_after_package = 0;
+ this.blank_lines_before_field = 0;
+ this.blank_lines_before_first_class_body_declaration = 0;
+ this.blank_lines_before_imports = 0;
+ this.blank_lines_before_member_type = 0;
+ this.blank_lines_before_method = 0;
+ this.blank_lines_before_new_chunk = 0;
+ this.blank_lines_before_package = 0;
+ this.blank_lines_between_type_declarations = 0;
+ this.blank_lines_at_beginning_of_method_body = 0;
+ this.indent_statements_compare_to_block = true;
+ this.indent_statements_compare_to_body = true;
+ this.indent_body_declarations_compare_to_type_header = true;
+ this.indent_breaks_compare_to_cases = true;
+ this.indent_switchstatements_compare_to_cases = true;
+ this.indent_switchstatements_compare_to_switch = true;
+ this.insert_new_line_after_annotation_on_member= true;
+ this.insert_new_line_after_annotation_on_parameter= false;
+ this.insert_new_line_after_annotation_on_local_variable= true;
+ this.insert_new_line_at_end_of_file_if_missing= false;
+ this.insert_new_line_after_opening_brace_in_array_initializer = false;
+ this.insert_new_line_before_catch_in_try_statement = false;
+ this.insert_new_line_before_closing_brace_in_array_initializer = false;
+ this.insert_new_line_before_else_in_if_statement = false;
+ this.insert_new_line_before_finally_in_try_statement = false;
+ this.insert_new_line_before_while_in_do_statement = false;
+ this.insert_new_line_in_empty_anonymous_type_declaration = true;
+ this.insert_new_line_in_empty_block = true;
+ this.insert_new_line_in_empty_method_body = true;
+ this.insert_new_line_in_empty_type_declaration = true;
+ this.insert_space_after_assignment_operator = true;
+ this.insert_space_after_binary_operator = true;
+ this.insert_space_after_closing_paren_in_cast = true;
+ this.insert_space_after_closing_brace_in_block = true;
+ this.insert_space_after_colon_in_assert = true;
+ this.insert_space_after_colon_in_case = true;
+ this.insert_space_after_colon_in_conditional = true;
+ this.insert_space_after_colon_in_labeled_statement = true;
+ this.insert_space_after_comma_in_allocation_expression = true;
+ this.insert_space_after_comma_in_array_initializer = true;
+ this.insert_space_after_comma_in_constructor_declaration_parameters = true;
+ this.insert_space_after_comma_in_constructor_declaration_throws = true;
+ this.insert_space_after_comma_in_explicit_constructor_call_arguments = true;
+ this.insert_space_after_comma_in_for_increments = true;
+ this.insert_space_after_comma_in_for_inits = true;
+ this.insert_space_after_comma_in_method_invocation_arguments = true;
+ this.insert_space_after_comma_in_method_declaration_parameters = true;
+ this.insert_space_after_comma_in_method_declaration_throws = true;
+ this.insert_space_after_comma_in_multiple_field_declarations = true;
+ this.insert_space_after_comma_in_multiple_local_declarations = true;
+ this.insert_space_after_comma_in_superinterfaces = true;
+ this.insert_space_after_opening_bracket_in_array_allocation_expression = false;
+ this.insert_space_after_opening_bracket_in_array_reference = false;
+ this.insert_space_after_opening_brace_in_array_initializer = false;
+ this.insert_space_after_opening_paren_in_cast = false;
+ this.insert_space_after_opening_paren_in_catch = false;
+ this.insert_space_after_opening_paren_in_constructor_declaration = false;
+ this.insert_space_after_opening_paren_in_for = false;
+ this.insert_space_after_opening_paren_in_if = false;
+ this.insert_space_after_opening_paren_in_method_declaration = false;
+ this.insert_space_after_opening_paren_in_method_invocation = false;
+ this.insert_space_after_opening_paren_in_parenthesized_expression = false;
+ this.insert_space_after_opening_paren_in_switch = false;
+ this.insert_space_after_opening_paren_in_synchronized = false;
+ this.insert_space_after_opening_paren_in_while = false;
+ this.insert_space_after_postfix_operator = false;
+ this.insert_space_after_prefix_operator = false;
+ this.insert_space_after_question_in_conditional = true;
+ this.insert_space_after_semicolon_in_for = true;
+ this.insert_space_after_unary_operator = false;
+ this.insert_space_before_assignment_operator = true;
+ this.insert_space_before_binary_operator = true;
+ this.insert_space_before_closing_brace_in_array_initializer = false;
+ this.insert_space_before_closing_bracket_in_array_allocation_expression = false;
+ this.insert_space_before_closing_bracket_in_array_reference = false;
+ this.insert_space_before_closing_paren_in_cast = false;
+ this.insert_space_before_closing_paren_in_catch = false;
+ this.insert_space_before_closing_paren_in_constructor_declaration = false;
+ this.insert_space_before_closing_paren_in_for = false;
+ this.insert_space_before_closing_paren_in_if = false;
+ this.insert_space_before_closing_paren_in_method_declaration = false;
+ this.insert_space_before_closing_paren_in_method_invocation = false;
+ this.insert_space_before_closing_paren_in_parenthesized_expression = false;
+ this.insert_space_before_closing_paren_in_switch = false;
+ this.insert_space_before_closing_paren_in_synchronized = false;
+ this.insert_space_before_closing_paren_in_while = false;
+ this.insert_space_before_colon_in_assert = true;
+ this.insert_space_before_colon_in_case = true;
+ this.insert_space_before_colon_in_conditional = true;
+ this.insert_space_before_colon_in_default = true;
+ this.insert_space_before_colon_in_labeled_statement = true;
+ this.insert_space_before_comma_in_allocation_expression = false;
+ this.insert_space_before_comma_in_array_initializer = false;
+ this.insert_space_before_comma_in_constructor_declaration_parameters = false;
+ this.insert_space_before_comma_in_constructor_declaration_throws = false;
+ this.insert_space_before_comma_in_explicit_constructor_call_arguments = false;
+ this.insert_space_before_comma_in_for_increments = false;
+ this.insert_space_before_comma_in_for_inits = false;
+ this.insert_space_before_comma_in_method_invocation_arguments = false;
+ this.insert_space_before_comma_in_method_declaration_parameters = false;
+ this.insert_space_before_comma_in_method_declaration_throws = false;
+ this.insert_space_before_comma_in_multiple_field_declarations = false;
+ this.insert_space_before_comma_in_multiple_local_declarations = false;
+ this.insert_space_before_comma_in_superinterfaces = false;
+ this.insert_space_before_opening_brace_in_anonymous_type_declaration = true;
+ this.insert_space_before_opening_brace_in_array_initializer = false;
+ this.insert_space_before_opening_brace_in_block = true;
+ this.insert_space_before_opening_brace_in_constructor_declaration = true;
+ this.insert_space_before_opening_brace_in_method_declaration = true;
+ this.insert_space_before_opening_brace_in_switch = true;
+ this.insert_space_before_opening_brace_in_type_declaration = true;
+ this.insert_space_before_opening_bracket_in_array_allocation_expression = false;
+ this.insert_space_before_opening_bracket_in_array_reference = false;
+ this.insert_space_before_opening_bracket_in_array_type_reference = false;
+ this.insert_space_before_opening_paren_in_catch = true;
+ this.insert_space_before_opening_paren_in_constructor_declaration = false;
+ this.insert_space_before_opening_paren_in_for = true;
+ this.insert_space_before_opening_paren_in_if = true;
+ this.insert_space_before_opening_paren_in_method_invocation = false;
+ this.insert_space_before_opening_paren_in_method_declaration = false;
+ this.insert_space_before_opening_paren_in_switch = true;
+ this.insert_space_before_opening_paren_in_synchronized = true;
+ this.insert_space_before_opening_paren_in_parenthesized_expression = false;
+ this.insert_space_before_opening_paren_in_while = true;
+ this.insert_space_before_postfix_operator = false;
+ this.insert_space_before_prefix_operator = false;
+ this.insert_space_before_question_in_conditional = true;
+ this.insert_space_before_semicolon = false;
+ this.insert_space_before_semicolon_in_for = false;
+ this.insert_space_before_unary_operator = false;
+ this.insert_space_between_brackets_in_array_type_reference = false;
+ this.insert_space_between_empty_braces_in_array_initializer = false;
+ this.insert_space_between_empty_brackets_in_array_allocation_expression = false;
+ this.insert_space_between_empty_parens_in_constructor_declaration = false;
+ this.insert_space_between_empty_parens_in_method_declaration = false;
+ this.insert_space_between_empty_parens_in_method_invocation = false;
+ this.compact_else_if = true;
+ this.keep_guardian_clause_on_one_line = false;
+ this.keep_else_statement_on_same_line = false;
+ this.keep_empty_array_initializer_on_one_line = true;
+ this.keep_simple_if_on_one_line = false;
+ this.keep_then_statement_on_same_line = false;
+ this.number_of_empty_lines_to_preserve = 1;
+ this.put_empty_statement_on_new_line = false;
+ this.tab_size = 4;
+ this.page_width = 80;
+ this.use_tab = true; // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=49081
+ this.wrapBeforeBinaryOperator = true;
+ this.never_indent_block_comments_on_first_column = false;
+ this.never_indent_line_comments_on_first_column = false;
+ }
+}
+
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptionsSetup.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptionsSetup.java
new file mode 100644
index 000000000..8ad243152
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptionsSetup.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.JavaCore;
+
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+
+public class TestOptionsSetup extends TestSetup {
+
+ public TestOptionsSetup(Test test) {
+ super(test);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ JavaCore.setOptions(TestOptions.getDefaultOptions());
+ TestOptions.initializeCodeGenerationOptions();
+ // Use load since restore doesn't really restore the defaults.
+ JavaPlugin.getDefault().getCodeTemplateStore().load();
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/HelloWorld.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/HelloWorld.java
new file mode 100644
index 000000000..11c8935b1
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/HelloWorld.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin.test;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.jdt.testplugin.JavaProjectHelper;
+
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.jdt.core.IClassFile;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+
+
+public class HelloWorld extends TestCase {
+
+ private IJavaProject fJProject;
+
+
+ public static Test suite() {
+ TestSuite suite= new TestSuite();
+ suite.addTest(new HelloWorld("test1"));
+ return suite;
+ }
+
+ public HelloWorld(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ fJProject= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ }
+
+
+ protected void tearDown() throws Exception {
+ JavaProjectHelper.delete(fJProject);
+ }
+
+ public void test1() throws Exception {
+ if (JavaProjectHelper.addRTJar(fJProject) == null) {
+ assertTrue("jdk not found", false);
+ return;
+ }
+
+ String name= "java/util/Vector.java";
+ IClassFile classfile= (IClassFile) fJProject.findElement(new Path(name));
+ assertTrue("classfile not found", classfile != null);
+
+ IType type= classfile.getType();
+ System.out.println("methods of Vector");
+ IMethod[] methods= type.getMethods();
+ for (int i= 0; i < methods.length; i++) {
+ System.out.println(methods[i].getElementName());
+ }
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/JavaTestCase.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/JavaTestCase.java
new file mode 100644
index 000000000..dbf9a19d5
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/JavaTestCase.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin.test;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.jdt.testplugin.JavaProjectHelper;
+
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IType;
+
+
+public class JavaTestCase extends TestCase {
+
+ private IJavaProject fJavaProject;
+
+ public JavaTestCase(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ TestSuite suite= new TestSuite();
+ suite.addTest(new JavaTestCase("doTest1"));
+ return suite;
+ }
+
+ /**
+ * Creates a new test Java project.
+ *
+ * @throws Exception in case of any problem
+ */
+ protected void setUp() throws Exception {
+ fJavaProject= JavaProjectHelper.createJavaProject("HelloWorldProject", "bin");
+
+ IPackageFragmentRoot root= JavaProjectHelper.addSourceContainer(fJavaProject, "src");
+ IPackageFragment pack= root.createPackageFragment("ibm.util", true, null);
+
+ ICompilationUnit cu= pack.getCompilationUnit("A.java");
+ IType type= cu.createType("public class A {\n}\n", null, true, null);
+ type.createMethod("public void a() {}\n", null, true, null);
+ type.createMethod("public void b(java.util.Vector v) {}\n", null, true, null);
+ }
+
+ /**
+ * Removes the test java project.
+ *
+ * @throws Exception in case of any problem
+ */
+ protected void tearDown () throws Exception {
+ JavaProjectHelper.delete(fJavaProject);
+ }
+
+ /*
+ * Basic test: Checks for created methods.
+ */
+ public void doTest1() throws Exception {
+
+ String name= "ibm/util/A.java";
+ ICompilationUnit cu= (ICompilationUnit) fJavaProject.findElement(new Path(name));
+ assertTrue("A.java must exist", cu != null);
+ IType type= cu.getType("A");
+ assertTrue("Type A must exist", type != null);
+
+ System.out.println("methods of A");
+ IMethod[] methods= type.getMethods();
+ for (int i= 0; i < methods.length; i++) {
+ System.out.println(methods[i].getElementName());
+ }
+ assertTrue("Should contain 2 methods", methods.length == 2);
+ }
+
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/AccessibilityTestPass.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/AccessibilityTestPass.java
new file mode 100644
index 000000000..168d28fdb
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/AccessibilityTestPass.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin.util;
+
+
+import java.util.ArrayList;
+
+
+public class AccessibilityTestPass implements IDialogTestPass {
+ private static final int CHECKLIST_SIZE = 5;
+
+ /**
+ * @see IDialogTestPass#title()
+ */
+ public String title() {
+ return "Test Pass: Accessibility";
+ }
+ /**
+ * @see IDialogTestPass#description()
+ */
+ public String description() {
+ return "Verify the accessibility of the dialogs.";
+ }
+ /**
+ * @see IDialogTestPass#label()
+ */
+ public String label() {
+ return "&Accessibility";
+ }
+ /**
+ * @see IDialogTestPass#checkListTexts()
+ */
+ public ArrayList checkListTexts() {
+ ArrayList list = new ArrayList(CHECKLIST_SIZE);
+ list.add("&1) all widgets are accessible by tabbing.");
+ list.add("&2) forwards and backwards tabbing is in a logical order");
+ list.add("&3) all the widgets with labels have an appropriate mnemonic.");
+ list.add("&4) there are no duplicate mnemonics.");
+ list.add("&5) selectable widgets can be selected using the spacebar.");
+ return list;
+ }
+ /**
+ * @see IDialogTestPass#failureTexts()
+ * Size of the return array must be the same size as the checkListTexts'
+ * ArrayList.
+ */
+ public String[] failureTexts() {
+ String[] failureText = new String[CHECKLIST_SIZE];
+ failureText[0] = "Some widgets aren't accessible by tabbing.";
+ failureText[1] = "Tabbing order is illogical.";
+ failureText[2] = "Missing or inappropriate mnemonics.";
+ failureText[3] = "Duplicate mnemonics.";
+ failureText[4] = "Some widgets cannot be selected using the spacebar.";
+ return failureText;
+ }
+ /**
+ * @see IDialogTestPass#queryText()
+ */
+ public String queryText() {
+ return "Is the accessibility of the dialog acceptable?";
+ }
+ /**
+ * @see IDialogTestPass#getID()
+ */
+ public int getID() {
+ return VerifyDialog.TEST_ACCESS;
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/DialogCheck.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/DialogCheck.java
new file mode 100644
index 000000000..9ddd130cd
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/DialogCheck.java
@@ -0,0 +1,219 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin.util;
+
+
+
+
+import junit.framework.Assert;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * A <code>DialogCheck</code> is used test a dialog in
+ * various ways.
+ * <p>
+ * For interactive tests use <code>assertDialog</code>.
+ * For automated tests use <code>assert DialogTexts</code>.
+ * </p>
+ */
+public class DialogCheck {
+ private DialogCheck() {
+ }
+ private static VerifyDialog _verifyDialog;
+
+
+ /**
+ * Asserts that a given dialog is not null and that it passes
+ * certain visual tests. These tests will be verified manually
+ * by the tester using an input dialog. Use this assert method
+ * to verify a dialog's sizing, initial focus, or accessiblity.
+ * To ensure that both the input dialog and the test dialog are
+ * accessible by the tester, the getShell() method should be used
+ * when creating the test dialog.
+ *
+ * Example usage:
+ * <code>Dialog dialog = new AboutDialog( DialogCheck.getShell() );
+ * DialogCheck.assertDialog(dialog, this);</code>
+ *
+ * @param dialog the test dialog to be verified.
+ */
+ public static void assertDialog(Dialog dialog) {
+ Assert.assertNotNull(dialog);
+ if (_verifyDialog.getShell() == null) {
+ //force the creation of the verify dialog
+ getShell();
+ }
+ if (_verifyDialog.open(dialog) == IDialogConstants.NO_ID) {
+ Assert.assertTrue(_verifyDialog.getFailureText(), false);
+ }
+ }
+
+
+ /**
+ * Automated test that checks all the labels and buttons of a dialog
+ * to make sure there is enough room to display all the text. Any
+ * text that wraps is only approximated and is currently not accurate.
+ *
+ * @param dialog the test dialog to be verified.
+ */
+ public static void assertDialogTexts(Dialog dialog) {
+ Assert.assertNotNull(dialog);
+ dialog.setBlockOnOpen(false);
+ dialog.open();
+ Shell shell = dialog.getShell();
+ verifyCompositeText(shell);
+ dialog.close();
+ }
+
+
+ /**
+ * This method should be called when creating dialogs to test. This
+ * ensures that the dialog's parent shell will be that of the
+ * verification dialog.
+ *
+ * @return Shell The shell of the verification dialog to be used as
+ * the parent shell of the test dialog.
+ */
+ public static Shell getShell() {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ _verifyDialog = new VerifyDialog(shell);
+ _verifyDialog.create();
+ return _verifyDialog.getShell();
+ }
+
+
+ /*
+ * Looks at all the child widgets of a given composite and
+ * verifies the text on all labels and widgets.
+ * @param composite The composite to look through
+ */
+ private static void verifyCompositeText(Composite composite) {
+ Control children[] = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ try {
+ //verify the text if the child is a button
+ verifyButtonText((Button) children[i]);
+ } catch (ClassCastException exNotButton) {
+ try {
+ //child is not a button, maybe a label
+ verifyLabelText((Label) children[i]);
+ } catch (ClassCastException exNotLabel) {
+ try {
+ //child is not a label, make a recursive call if it is a composite
+ verifyCompositeText((Composite) children[i]);
+ } catch (ClassCastException exNotComposite) {
+ //the child is not a button, label, or composite - ignore it.
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * Verifies that a given button is large enough to display its text.
+ * @param button The button to verify,
+ */
+ private static void verifyButtonText(Button button) {
+ String widget = button.toString();
+ Point size = button.getSize();
+
+
+ //compute the size with no line wrapping
+ Point preferred = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ //if (size.y/preferred.y) == X, then label spans X lines, so divide
+ //the calculated value of preferred.x by X
+ if (preferred.y * size.y > 0) {
+ preferred.y /= countLines(button.getText()); //check for '\n\'
+ if (size.y / preferred.y > 1) {
+ preferred.x /= (size.y / preferred.y);
+ }
+ }
+
+
+ String message =
+ new StringBuffer("Warning: ")
+ .append(widget)
+ .append("\n\tActual Width -> ")
+ .append(size.x)
+ .append("\n\tRecommended Width -> ")
+ .append(preferred.x)
+ .toString();
+ if (preferred.x > size.x) {
+ //close the dialog
+ button.getShell().dispose();
+ Assert.assertTrue(message.toString(), false);
+ }
+ }
+
+ /*
+ * Verifies that a given label is large enough to display its text.
+ * @param label The label to verify,
+ */
+ private static void verifyLabelText(Label label) {
+ String widget = label.toString();
+ Point size = label.getSize();
+
+
+ //compute the size with no line wrapping
+ Point preferred = label.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ //if (size.y/preferred.y) == X, then label spans X lines, so divide
+ //the calculated value of preferred.x by X
+ if (preferred.y * size.y > 0) {
+ preferred.y /= countLines(label.getText());
+ if (size.y / preferred.y > 1) {
+ preferred.x /= (size.y / preferred.y);
+ }
+ }
+ String message =
+ new StringBuffer("Warning: ")
+ .append(widget)
+ .append("\n\tActual Width -> ")
+ .append(size.x)
+ .append("\n\tRecommended Width -> ")
+ .append(preferred.x)
+ .toString();
+ if (preferred.x > size.x) {
+ //close the dialog
+ label.getShell().dispose();
+ Assert.assertTrue(message.toString(), false);
+ }
+ }
+
+ /*
+ * Counts the number of lines in a given String.
+ * For example, if a string contains one (1) newline character,
+ * a value of two (2) would be returned.
+ * @param text The string to look through.
+ * @return int the number of lines in text.
+ */
+ private static int countLines(String text) {
+ int newLines = 1;
+ for (int i = 0; i < text.length(); i++) {
+ if (text.charAt(i) == '\n') {
+ newLines++;
+ }
+ }
+ return newLines;
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/DisplayHelper.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/DisplayHelper.java
new file mode 100644
index 000000000..2714cbe78
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/DisplayHelper.java
@@ -0,0 +1,589 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin.util;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import junit.framework.Assert;
+
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Runs the event loop of the given display until {@link #condition()} becomes
+ * <code>true</code> or no events have occurred for the supplied timeout.
+ * Between running the event loop, {@link Display#sleep()} is called.
+ * <p>
+ * There is a caveat: the given timeouts must be long enough that the calling
+ * thread can enter <code>Display.sleep()</code> before the timeout elapses,
+ * otherwise, the waiter may time out before <code>sleep</code> is called and
+ * the sleeping thread may never be waken up.
+ * </p>
+ *
+ * @since 3.1
+ */
+public abstract class DisplayHelper {
+
+ /**
+ * Controls if the timeout is used. For debugging use true, false otherwise
+ */
+ private static final boolean DISABLE_TIMEOUT= false;
+
+ /**
+ * Creates a new instance.
+ */
+ protected DisplayHelper() {
+ }
+
+ /**
+ * Until {@link #condition()} becomes <code>true</code> or the timeout
+ * elapses, call {@link Display#sleep()} and run the event loop.
+ * <p>
+ * If <code>timeout &lt; 0</code>, the event loop is never driven and
+ * only the condition is checked. If <code>timeout == 0</code>, the event
+ * loop is driven at most once, but <code>Display.sleep()</code> is never
+ * invoked.
+ * </p>
+ *
+ * @param display the display to run the event loop of
+ * @param timeout the timeout in milliseconds
+ * @return <code>true</code> if the condition became <code>true</code>,
+ * <code>false</code> if the timeout elapsed
+ */
+ public final boolean waitForCondition(Display display, long timeout) {
+ // if the condition already holds, succeed
+ if (condition())
+ return true;
+
+ if (timeout < 0)
+ return false;
+
+ // if driving the event loop once makes the condition hold, succeed
+ // without spawning a thread.
+ driveEventQueue(display);
+ if (condition())
+ return true;
+
+ // if the timeout is negative or zero, fail
+ if (timeout == 0)
+ return false;
+
+ // repeatedly sleep until condition becomes true or timeout elapses
+ DisplayWaiter waiter= new DisplayWaiter(display);
+ DisplayWaiter.Timeout timeoutState= waiter.start(timeout);
+ boolean condition;
+ try {
+ do {
+ if (display.sleep())
+ driveEventQueue(display);
+ condition= condition();
+ } while (!condition && !timeoutState.hasTimedOut());
+ } finally {
+ waiter.stop();
+ }
+ return condition;
+ }
+
+ /**
+ * Call {@link Display#sleep()} and run the event loop until the given
+ * timeout has elapsed.
+ * <p>
+ * If <code>timeout &lt; 0</code>, nothing happens. If
+ * <code>timeout == 0</code>, the event loop is driven exactly once, but
+ * <code>Display.sleep()</code> is never invoked.
+ * </p>
+ *
+ * @param display the display to run the event loop of
+ * @param millis the timeout in milliseconds
+ */
+ public static void sleep(Display display, long millis) {
+ new DisplayHelper() {
+ public boolean condition() {
+ return false;
+ }
+ }.waitForCondition(display, millis);
+ }
+
+ /**
+ * The condition which has to be met in order for {@link #waitForCondition(Display, long)} to
+ * return before the timeout elapses.
+ *
+ * @return <code>true</code> if the condition is met, <code>false</code> if the event loop
+ * should be driven some more
+ */
+ protected abstract boolean condition();
+
+ /**
+ * Runs the event loop on the given display.
+ *
+ * @param display the display
+ * @return if <code>display.readAndDispatch</code> returned
+ * <code>true</code> at least once
+ */
+ private static boolean driveEventQueue(Display display) {
+ boolean events= false;
+ while (display.readAndDispatch()) {
+ events= true;
+ }
+ return events;
+ }
+
+ /**
+ * Until {@link #condition()} becomes <code>true</code> or the timeout
+ * elapses, call {@link Display#sleep()} and run the event loop.
+ * <p>
+ * If <code>timeout &lt; 0</code>, the event loop is never driven and
+ * only the condition is checked. If <code>timeout == 0</code>, the event
+ * loop is driven at most once, but <code>Display.sleep()</code> is never
+ * invoked.
+ * </p>
+ * <p>
+ * The condition gets rechecked every <code>interval</code> milliseconds, even
+ * if no events were read from the queue.
+ * </p>
+ *
+ * @param display the display to run the event loop of
+ * @param timeout the timeout in milliseconds
+ * @param interval the interval to re-check the condition in milliseconds
+ * @return <code>true</code> if the condition became <code>true</code>,
+ * <code>false</code> if the timeout elapsed
+ */
+ public final boolean waitForCondition(Display display, long timeout, long interval) {
+ // if the condition already holds, succeed
+ if (condition())
+ return true;
+
+ if (timeout < 0)
+ return false;
+
+ // if driving the event loop once makes the condition hold, succeed
+ // without spawning a thread.
+ driveEventQueue(display);
+ if (condition())
+ return true;
+
+ // if the timeout is negative or zero, fail
+ if (timeout == 0)
+ return false;
+
+ // repeatedly sleep until condition becomes true or timeout elapses
+ DisplayWaiter waiter= new DisplayWaiter(display, true);
+ long currentTimeMillis= System.currentTimeMillis();
+ long finalTimeout= timeout + currentTimeMillis;
+ if (finalTimeout < currentTimeMillis)
+ finalTimeout= Long.MAX_VALUE;
+ boolean condition;
+ try {
+ do {
+ waiter.restart(interval);
+ if (display.sleep())
+ driveEventQueue(display);
+ condition= condition();
+ } while (!condition && (DISABLE_TIMEOUT || finalTimeout > System.currentTimeMillis()));
+ } finally {
+ waiter.stop();
+ }
+ return condition;
+ }
+
+}
+
+/**
+ * Implements the thread that will wait for the timeout and wake up the display
+ * so it does not wait forever. The thread may be restarted after it was stopped
+ * or timed out.
+ *
+ * @since 3.1
+ */
+final class DisplayWaiter {
+ /**
+ * Timeout state of a display waiter thread.
+ */
+ public final class Timeout {
+ private boolean fTimeoutState= false;
+ /**
+ * Returns <code>true</code> if the timeout has been reached,
+ * <code>false</code> if not.
+ *
+ * @return <code>true</code> if the timeout has been reached,
+ * <code>false</code> if not
+ */
+ public boolean hasTimedOut() {
+ synchronized (fMutex) {
+ return fTimeoutState;
+ }
+ }
+ void setTimedOut(boolean timedOut) {
+ fTimeoutState= timedOut;
+ }
+ Timeout(boolean initialState) {
+ fTimeoutState= initialState;
+ }
+ }
+
+ // configuration
+ private final Display fDisplay;
+ private final Object fMutex= new Object();
+ private final boolean fKeepRunningOnTimeout;
+
+ /* State -- possible transitions:
+ *
+ * STOPPED -> RUNNING
+ * RUNNING -> STOPPED
+ * RUNNING -> IDLE
+ * IDLE -> RUNNING
+ * IDLE -> STOPPED
+ */
+ private static final int RUNNING= 1 << 1;
+ private static final int STOPPED= 1 << 2;
+ private static final int IDLE= 1 << 3;
+
+ /** The current state. */
+ private int fState;
+ /** The time in milliseconds (see Date) that the timeout will occur. */
+ private long fNextTimeout;
+ /** The thread. */
+ private Thread fCurrentThread;
+ /** The timeout state of the current thread. */
+ private Timeout fCurrentTimeoutState;
+
+ /**
+ * Creates a new instance on the given display and timeout.
+ *
+ * @param display the display to run the event loop of
+ */
+ public DisplayWaiter(Display display) {
+ this(display, false);
+ }
+
+ /**
+ * Creates a new instance on the given display and timeout.
+ *
+ * @param display the display to run the event loop of
+ * @param keepRunning <code>true</code> if the thread should be kept
+ * running after timing out
+ */
+ public DisplayWaiter(Display display, boolean keepRunning) {
+ Assert.assertNotNull(display);
+ fDisplay= display;
+ fState= STOPPED;
+ fKeepRunningOnTimeout= keepRunning;
+ }
+
+ /**
+ * Starts the timeout thread if it is not currently running. Nothing happens
+ * if a thread is already running.
+ *
+ * @param delay the delay from now in milliseconds
+ * @return the timeout state which can be queried for its timed out status
+ */
+ public Timeout start(long delay) {
+ Assert.assertTrue(delay > 0);
+ synchronized (fMutex) {
+ switch (fState) {
+ case STOPPED:
+ startThread();
+ setNextTimeout(delay);
+ break;
+ case IDLE:
+ unhold();
+ setNextTimeout(delay);
+ break;
+ }
+
+ return fCurrentTimeoutState;
+ }
+ }
+
+ /**
+ * Sets the next timeout to <em>current time</em> plus <code>delay</code>.
+ *
+ * @param delay the delay until the next timeout occurs in milliseconds from
+ * now
+ */
+ private void setNextTimeout(long delay) {
+ long currentTimeMillis= System.currentTimeMillis();
+ long next= currentTimeMillis + delay;
+ if (next > currentTimeMillis)
+ fNextTimeout= next;
+ else
+ fNextTimeout= Long.MAX_VALUE;
+ }
+
+ /**
+ * Starts the thread if it is not currently running; resets the timeout if
+ * it is.
+ *
+ * @param delay the delay from now in milliseconds
+ * @return the timeout state which can be queried for its timed out status
+ */
+ public Timeout restart(long delay) {
+ Assert.assertTrue(delay > 0);
+ synchronized (fMutex) {
+ switch (fState) {
+ case STOPPED:
+ startThread();
+ break;
+ case IDLE:
+ unhold();
+ break;
+ }
+ setNextTimeout(delay);
+
+ return fCurrentTimeoutState;
+ }
+ }
+
+ /**
+ * Stops the thread if it is running. If not, nothing happens. Another
+ * thread may be started by calling {@link #start(long)} or
+ * {@link #restart(long)}.
+ */
+ public void stop() {
+ synchronized (fMutex) {
+ if (tryTransition(RUNNING | IDLE, STOPPED))
+ fMutex.notifyAll();
+ }
+ }
+
+ /**
+ * Puts the reaper thread on hold but does not stop it. It may be restarted
+ * by calling {@link #start(long)} or {@link #restart(long)}.
+ */
+ public void hold() {
+ synchronized (fMutex) {
+ // nothing to do if there is no thread
+ if (tryTransition(RUNNING, IDLE))
+ fMutex.notifyAll();
+ }
+ }
+
+ /**
+ * Transition to <code>RUNNING</code> and clear the timed out flag. Assume
+ * current state is <code>IDLE</code>.
+ */
+ private void unhold() {
+ checkedTransition(IDLE, RUNNING);
+ fCurrentTimeoutState= new Timeout(false);
+ fMutex.notifyAll();
+ }
+
+ /**
+ * Start the thread. Assume the current state is <code>STOPPED</code>.
+ */
+ private void startThread() {
+ checkedTransition(STOPPED, RUNNING);
+ fCurrentTimeoutState= new Timeout(false);
+ fCurrentThread= new Thread() {
+ /**
+ * Exception thrown when a thread notices that it has been stopped
+ * and a new thread has been started.
+ */
+ final class ThreadChangedException extends Exception {
+ private static final long serialVersionUID= 1L;
+ }
+
+ /*
+ * @see java.lang.Runnable#run()
+ */
+ public void run() {
+ try {
+ run2();
+ } catch (InterruptedException e) {
+ // ignore and end the thread - we never interrupt ourselves,
+ // so it must be an external entity that interrupted us
+ Logger.global.log(Level.FINE, "", e);
+ } catch (ThreadChangedException e) {
+ // the thread was stopped and restarted before we got out
+ // of a wait - we're no longer used
+ // we might have been notified instead of the current thread,
+ // so wake it up
+ Logger.global.log(Level.FINE, "", e);
+ synchronized (fMutex) {
+ fMutex.notifyAll();
+ }
+ }
+ }
+
+ /**
+ * Runs the thread.
+ *
+ * @throws InterruptedException if the thread was interrupted
+ * @throws ThreadChangedException if the thread changed
+ */
+ private void run2() throws InterruptedException, ThreadChangedException {
+ synchronized (fMutex) {
+ checkThread();
+ tryHold(); // wait / potential state change
+ assertStates(STOPPED | RUNNING);
+
+ while (isState(RUNNING)) {
+ waitForTimeout(); // wait / potential state change
+
+ if (isState(RUNNING))
+ timedOut(); // state change
+ assertStates(STOPPED | IDLE);
+
+ tryHold(); // wait / potential state change
+ assertStates(STOPPED | RUNNING);
+ }
+ assertStates(STOPPED);
+ }
+ }
+
+ /**
+ * Check whether the current thread is this thread, throw an
+ * exception otherwise.
+ *
+ * @throws ThreadChangedException if the current thread changed
+ */
+ private void checkThread() throws ThreadChangedException {
+ if (fCurrentThread != this)
+ throw new ThreadChangedException();
+ }
+
+ /**
+ * Waits until the next timeout occurs.
+ *
+ * @throws InterruptedException if the thread was interrupted
+ * @throws ThreadChangedException if the thread changed
+ */
+ private void waitForTimeout() throws InterruptedException, ThreadChangedException {
+ long delta;
+ while (isState(RUNNING) && (delta = fNextTimeout - System.currentTimeMillis()) > 0) {
+ delta= Math.max(delta, 50); // wait at least 50ms in order to avoid timing out before the display is going to sleep
+ Logger.global.finest("sleeping for " + delta + "ms");
+ fMutex.wait(delta);
+ checkThread();
+ }
+ }
+
+ /**
+ * Sets the timed out flag and wakes up the display. Transitions to
+ * <code>IDLE</code> (if in keep-running mode) or
+ * <code>STOPPED</code>.
+ */
+ private void timedOut() {
+ Logger.global.finer("timed out");
+ fCurrentTimeoutState.setTimedOut(true);
+ fDisplay.wake(); // wake up call!
+ if (fKeepRunningOnTimeout)
+ checkedTransition(RUNNING, IDLE);
+ else
+ checkedTransition(RUNNING, STOPPED);
+ }
+
+ /**
+ * Waits while the state is <code>IDLE</code>, then returns. The
+ * state must not be <code>RUNNING</code> when calling this
+ * method. The state is either <code>STOPPED</code> or
+ * <code>RUNNING</code> when the method returns.
+ *
+ * @throws InterruptedException if the thread was interrupted
+ * @throws ThreadChangedException if the thread has changed while on
+ * hold
+ */
+ private void tryHold() throws InterruptedException, ThreadChangedException {
+ while (isState(IDLE)) {
+ fMutex.wait(0);
+ checkThread();
+ }
+ assertStates(STOPPED | RUNNING);
+ }
+ };
+
+ fCurrentThread.start();
+ }
+
+ /**
+ * Transitions to <code>nextState</code> if the current state is one of
+ * <code>possibleStates</code>. Returns <code>true</code> if the
+ * transition happened, <code>false</code> otherwise.
+ *
+ * @param possibleStates the states which trigger a transition
+ * @param nextState the state to transition to
+ * @return <code>true</code> if the transition happened,
+ * <code>false</code> otherwise
+ */
+ private boolean tryTransition(int possibleStates, int nextState) {
+ if (isState(possibleStates)) {
+ Logger.global.finer(name(fState) + " > " + name(nextState) + " (" + name(possibleStates) + ")");
+ fState= nextState;
+ return true;
+ }
+ Logger.global.finest("noTransition" + name(fState) + " !> " + name(nextState) + " (" + name(possibleStates) + ")");
+ return false;
+ }
+
+ /**
+ * Checks the <code>possibleStates</code> and throws an assertion if it is
+ * not met, then transitions to <code>nextState</code>.
+ *
+ * @param possibleStates the allowed states
+ * @param nextState the state to transition to
+ */
+ private void checkedTransition(int possibleStates, int nextState) {
+ assertStates(possibleStates);
+ Logger.global.finer(name(fState) + " > " + name(nextState));
+ fState= nextState;
+ }
+
+ /**
+ * Implements state consistency checking.
+ *
+ * @param states the allowed states
+ * @throws junit.framework.AssertionFailedError if the current state is not
+ * in <code>states</code>
+ */
+ private void assertStates(int states) {
+ Assert.assertTrue("illegal state", isState(states));
+ }
+
+ /**
+ * Answers <code>true</code> if the current state is in the given
+ * <code>states</code>.
+ *
+ * @param states the possible states
+ * @return <code>true</code> if the current state is in the given states,
+ * <code>false</code> otherwise
+ */
+ private boolean isState(int states) {
+ return (states & fState) == fState;
+ }
+
+ /**
+ * Pretty print the given states.
+ *
+ * @param states the states
+ * @return a string representation of the states
+ */
+ private String name(int states) {
+ StringBuffer buf= new StringBuffer();
+ boolean comma= false;
+ if ((states & RUNNING) == RUNNING) {
+ buf.append("RUNNING");
+ comma= true;
+ }
+ if ((states & STOPPED) == STOPPED) {
+ if (comma)
+ buf.append(",");
+ buf.append("STOPPED");
+ comma= true;
+ }
+ if ((states & IDLE) == IDLE) {
+ if (comma)
+ buf.append(",");
+ buf.append("IDLE");
+ }
+ return buf.toString();
+ }
+
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/FailureDialog.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/FailureDialog.java
new file mode 100644
index 000000000..e8eaf46e2
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/FailureDialog.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin.util;
+
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.JFaceResources;
+
+
+/*
+ * A dialog for collecting notes from the tester regarding
+ * the failure of a test.
+ */
+public class FailureDialog extends Dialog {
+ private Text _text;
+ private String _log;
+ private int SIZING_TEXT_WIDTH = 400;
+ private int SIZING_TEXT_HEIGHT = 200;
+
+ /*
+ * Constructor for FailureDialog
+ */
+ public FailureDialog(Shell parentShell) {
+ super(parentShell);
+ }
+ /* (non-Javadoc)
+ * Method declared on Window.
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Dialog Test Failed");
+ }
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, "&OK", true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected Control createDialogArea(Composite parent) {
+ // page group
+ Composite composite = (Composite)super.createDialogArea(parent);
+ composite.setSize( composite.computeSize(SWT.DEFAULT, SWT.DEFAULT) );
+
+ Label label = new Label(composite, SWT.WRAP);
+ label.setText("&Enter a note regarding the failure:");
+
+ _text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ _text.setFont( JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT) );
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.widthHint = SIZING_TEXT_WIDTH;
+ data.heightHint = SIZING_TEXT_HEIGHT;
+ _text.setLayoutData(data);
+
+ return composite;
+ }
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void okPressed() {
+ _log = _text.getText();
+ super.okPressed();
+ }
+ /*
+ * @return String the text contained in the input area of
+ * the dialog.
+ */
+ String getText() {
+ if (_log == null) {
+ return "Empty entry.";
+ } else {
+ return _log;
+ }
+ }
+ /*
+ * Sets the text of the input area. This should only be
+ * called to set the initial text so only call before invoking
+ * open().
+ */
+ void setText(String text) {
+ _text.setText(text);
+ }
+ /*
+ * Returns a string representation of this class which
+ * the text contained in the input area of the dialog.
+ */
+ public String toString() {
+ return getText();
+ }
+}
+
+
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/FocusTestPass.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/FocusTestPass.java
new file mode 100644
index 000000000..9d4231781
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/FocusTestPass.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin.util;
+
+
+
+import java.util.ArrayList;
+
+
+/*
+ * This test pass verifies the initial focus of a dialog
+ * when it is given focus.
+ */
+public class FocusTestPass implements IDialogTestPass {
+ private static final int CHECKLIST_SIZE = 1;
+
+
+ /**
+ * @see IDialogTestPass#title()
+ */
+ public String title() {
+ return "Test Pass: Initial Focus";
+ }
+ /**
+ * @see IDialogTestPass#description()
+ */
+ public String description() {
+ return "Verify the initial focus of the dialogs.";
+ }
+ /**
+ * @see IDialogTestPass#label()
+ */
+ public String label() {
+ return "&Initial Focus";
+ }
+ /**
+ * @see IDialogTestPass#checkListTexts()
+ */
+ public ArrayList checkListTexts() {
+ ArrayList list = new ArrayList(CHECKLIST_SIZE);
+ list.add("&1) the initial focus is appropriate.");
+ return list;
+ }
+ /**
+ * @see IDialogTestPass#failureTexts()
+ * Size of the return array must be the same size as the checkListTexts'
+ * ArrayList.
+ */
+ public String[] failureTexts() {
+ String[] failureText = new String[CHECKLIST_SIZE];
+ failureText[0] = "The initial focus is inappropriate.";
+ return failureText;
+ }
+ /**
+ * @see IDialogTestPass#queryText()
+ */
+ public String queryText() {
+ return "Is the initial focus of the dialog correct?";
+ }
+ /**
+ * @see IDialogTestPass#getID()
+ */
+ public int getID() {
+ return VerifyDialog.TEST_FOCUS;
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/IDialogTestPass.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/IDialogTestPass.java
new file mode 100644
index 000000000..af4df6714
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/IDialogTestPass.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin.util;
+
+
+import java.util.ArrayList;
+
+
+/*
+ * Interface to describe a visual test pass for a dialog test.
+ */
+public interface IDialogTestPass {
+ /*
+ * @return String The title of the test pass.
+ */
+ public String title();
+ /*
+ * @return String The description of the test pass.
+ */
+ public String description();
+ /*
+ * @return String The label of the test pass to be used
+ * in a selection list. The return includes an '&'
+ * if a mnemonic is desired.
+ */
+ public String label();
+ /*
+ * @return ArrayList A list of items to appear in a checklist.
+ * The items in the list must be Strings and should include an
+ * '&' if a mnemonic is desired.
+ */
+ public ArrayList checkListTexts();
+ /*
+ * @return String[] Associated failure messages that correspond
+ * to the checklist items. The size of this array should be the
+ * same size as the checklist.
+ */
+ public String[] failureTexts();
+ /*
+ * @return String The test that corresponds to the test pass to
+ * which the tester will respond with a 'yes' or 'no'.
+ */
+ public String queryText();
+ /*
+ * @return int A unique number that identifies the test pass.
+ */
+ public int getID();
+}
+
+
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/SizingTestPass.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/SizingTestPass.java
new file mode 100644
index 000000000..7a9502c63
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/SizingTestPass.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin.util;
+
+
+
+import java.util.ArrayList;
+
+
+/*
+ * This test pass verifies visually the sizing of the dialog and its
+ * widgets.
+ */
+class SizingTestPass implements IDialogTestPass {
+ private static final int CHECKLIST_SIZE = 5;
+
+
+ /**
+ * @see IDialogTestPass#title()
+ */
+ public String title() {
+ return "Test Pass: Sizing and Display";
+ }
+ /**
+ * @see IDialogTestPass#description()
+ */
+ public String description() {
+ return "Verify the sizing and display of the dialogs and widgets.";
+ }
+ /**
+ * @see IDialogTestPass#label()
+ */
+ public String label() {
+ return "&Sizing and Display";
+ }
+ /**
+ * @see IDialogTestPass#checkListTexts()
+ */
+ public ArrayList checkListTexts() {
+ ArrayList list = new ArrayList(CHECKLIST_SIZE);
+ list.add("&1) the correct dialog displays.");
+ list.add("&2) the dialog is an appropriate size for the required resolution (1024x768).");
+ list.add("&3) the texts are correct and not cut off.");
+ list.add("&4) all strings have been externalized properly.");
+ list.add("&5) all the widgets are viewable and not cut off.");
+ return list;
+ }
+ /**
+ * @see IDialogTestPass#failureTexts()
+ * Size of the return array must be the same size as the checkListTexts'
+ * ArrayList.
+ */
+ public String[] failureTexts() {
+ String[] failureText = new String[CHECKLIST_SIZE];
+ failureText[0] = "The wrong dialog displayed.";
+ failureText[1] = "The dialog is too large for the required resolution.";
+ failureText[2] = "Text labels are wrong or cut off.";
+ failureText[3] = "Some strings have not been externalized properly.";
+ failureText[4] = "Some widgets are cut off.";
+ return failureText;
+ }
+ /**
+ * @see IDialogTestPass#queryText()
+ */
+ public String queryText() {
+ return "Is the sizing and display of the dialog correct?";
+ }
+ /**
+ * @see IDialogTestPass#getID()
+ */
+ public int getID() {
+ return VerifyDialog.TEST_SIZING;
+ }
+}
diff --git a/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/VerifyDialog.java b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/VerifyDialog.java
new file mode 100644
index 000000000..36b6782b6
--- /dev/null
+++ b/testplugins/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/util/VerifyDialog.java
@@ -0,0 +1,313 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.testplugin.util;
+
+
+import java.util.Iterator;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.ShellAdapter;
+import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.graphics.Point;