PageRenderTime 53ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/eclipse-plugin/plugins/com.google.test.metric.eclipse.ui/src/main/java/com/google/test/metric/eclipse/ui/internal/compilation/TestabilityCompilationParticipant.java

http://testability-explorer.googlecode.com/
Java | 65 lines | 38 code | 7 blank | 20 comment | 2 complexity | 743c4b7ee1d0b1e7f43dfa315ec49b96 MD5 | raw file
Possible License(s): Apache-2.0
  1. /*
  2. * Copyright 2009 Google Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.google.test.metric.eclipse.ui.internal.compilation;
  17. import com.google.test.metric.eclipse.internal.util.Logger;
  18. import com.google.test.metric.eclipse.internal.util.TestabilityConstants;
  19. import com.google.test.metric.eclipse.internal.util.TestabilityLaunchConfigurationHelper;
  20. import org.eclipse.core.runtime.CoreException;
  21. import org.eclipse.debug.core.ILaunch;
  22. import org.eclipse.debug.core.ILaunchConfiguration;
  23. import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
  24. import org.eclipse.jdt.core.IJavaProject;
  25. import org.eclipse.jdt.core.compiler.CompilationParticipant;
  26. /**
  27. * Runs the testability explorer once compilation / build is finished.
  28. *
  29. * @author shyamseshadri@google.com (Shyam Seshadri)
  30. */
  31. public class TestabilityCompilationParticipant extends CompilationParticipant {
  32. private Logger logger = new Logger();
  33. private TestabilityLaunchConfigurationHelper configurationHelper =
  34. new TestabilityLaunchConfigurationHelper();
  35. public TestabilityCompilationParticipant() {
  36. }
  37. @Override
  38. public boolean isActive(IJavaProject project) {
  39. return configurationHelper.isExistingLaunchConfigurationWithRunOnBuild(
  40. project.getElementName());
  41. }
  42. @Override
  43. public void buildFinished(IJavaProject project) {
  44. super.buildFinished(project);
  45. ILaunchConfiguration launchConfiguration =
  46. configurationHelper.getLaunchConfiguration(project.getElementName());
  47. if (launchConfiguration != null) {
  48. try {
  49. ILaunchConfigurationWorkingCopy workingCopy = launchConfiguration.getWorkingCopy();
  50. workingCopy.setAttribute(
  51. TestabilityConstants.CONFIGURATION_ATTR_RUNNING_IN_COMPILATION_MODE, true);
  52. ILaunch launch = workingCopy.launch(TestabilityConstants.TESTABILITY_MODE, null);
  53. } catch (CoreException e) {
  54. logger.logException(e);
  55. }
  56. }
  57. }
  58. }