update copyright
[fedora-idea.git] / plugins / testng / src / com / theoryinpractice / testng / configuration / TestNGPackageConfigurationProducer.java
blob44334d190bfbb23c790fc74aa45d41746802b273
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.theoryinpractice.testng.configuration;
18 import com.intellij.execution.Location;
19 import com.intellij.execution.actions.ConfigurationContext;
20 import com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl;
21 import com.intellij.openapi.project.Project;
22 import com.intellij.psi.PsiElement;
23 import com.intellij.psi.PsiPackage;
24 import com.theoryinpractice.testng.model.TestData;
25 import com.theoryinpractice.testng.model.TestType;
27 public class TestNGPackageConfigurationProducer extends TestNGConfigurationProducer {
28 private PsiPackage myPackage = null;
30 protected RunnerAndConfigurationSettingsImpl createConfigurationByElement(final Location location, final ConfigurationContext context) {
31 final Project project = location.getProject();
32 final PsiElement element = location.getPsiElement();
33 myPackage = checkPackage(element);
34 if (myPackage == null) return null;
35 RunnerAndConfigurationSettingsImpl settings = cloneTemplateConfiguration(project, context);
36 final TestNGConfiguration configuration = (TestNGConfiguration)settings.getConfiguration();
37 final TestData data = configuration.data;
38 data.PACKAGE_NAME = myPackage.getQualifiedName();
39 data.TEST_OBJECT = TestType.PACKAGE.getType();
40 data.setScope(setupPackageConfiguration(context, project, configuration, data.getScope()));
41 configuration.setGeneratedName();
42 return settings;
45 public PsiElement getSourceElement() {
46 return myPackage;
49 public int compareTo(final Object o) {
50 return PREFERED;