update copyright
[fedora-idea.git] / plugins / testng / src / com / theoryinpractice / testng / configuration / browser / GroupBrowser.java
blobdcc4940f4df8438dd3754910a4b57acd8e501d90
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.browser;
18 import com.intellij.execution.configuration.BrowseModuleValueActionListener;
19 import com.intellij.openapi.module.Module;
20 import com.intellij.openapi.project.Project;
21 import com.intellij.openapi.ui.Messages;
22 import com.intellij.psi.PsiClass;
23 import com.intellij.psi.search.GlobalSearchScope;
24 import com.theoryinpractice.testng.configuration.TestNGConfigurationEditor;
25 import com.theoryinpractice.testng.model.TestClassFilter;
26 import com.theoryinpractice.testng.util.TestNGUtil;
27 import org.jetbrains.annotations.Nullable;
29 /**
30 * @author Hani Suleiman
31 * Date: Jul 21, 2005
32 * Time: 4:29:00 PM
34 public class GroupBrowser extends BrowseModuleValueActionListener
36 private final TestNGConfigurationEditor editor;
38 public GroupBrowser(Project project, TestNGConfigurationEditor editor) {
39 super(project);
40 this.editor = editor;
43 @Nullable
44 @Override
45 protected String showDialog() {
46 TestClassFilter filter;
47 Module module = editor.getModuleSelector().getModule();
48 if (module == null) {
49 filter = new TestClassFilter(GlobalSearchScope.projectScope(getProject()), getProject(), false);
51 else {
52 filter = new TestClassFilter(GlobalSearchScope.moduleScope(module), getProject(), false);
54 PsiClass[] classes = TestNGUtil.getAllTestClasses(filter, true);
55 if(classes.length == 0) {
56 Messages.showMessageDialog(getField(), "No tests found in project", "Cannot Browse Groups", Messages.getInformationIcon());
57 return null;
58 } else {
59 return GroupList.showDialog(classes, getField());