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
;
30 * @author Hani Suleiman
34 public class GroupBrowser
extends BrowseModuleValueActionListener
36 private final TestNGConfigurationEditor editor
;
38 public GroupBrowser(Project project
, TestNGConfigurationEditor editor
) {
45 protected String
showDialog() {
46 TestClassFilter filter
;
47 Module module
= editor
.getModuleSelector().getModule();
49 filter
= new TestClassFilter(GlobalSearchScope
.projectScope(getProject()), getProject(), false);
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());
59 return GroupList
.showDialog(classes
, getField());