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 org
.jetbrains
.idea
.maven
.navigator
;
18 import com
.intellij
.openapi
.project
.Project
;
19 import com
.intellij
.ui
.treeStructure
.NullNode
;
20 import com
.intellij
.ui
.treeStructure
.SimpleNode
;
21 import org
.jetbrains
.idea
.maven
.project
.MavenProject
;
24 import java
.awt
.event
.ActionEvent
;
26 public class SelectMavenProjectDialog
extends SelectFromMavenProjectsDialog
{
27 private MavenProject myResult
;
29 public SelectMavenProjectDialog(Project project
, final MavenProject current
) {
30 super(project
, "Select Maven Project", MavenProjectsStructure
.ProjectNode
.class, new NodeSelector() {
31 public boolean shouldSelect(SimpleNode node
) {
32 if (node
instanceof MavenProjectsStructure
.ProjectNode
) {
33 return ((MavenProjectsStructure
.ProjectNode
)node
).getMavenProject() == current
;
43 protected Action
[] createActions() {
44 Action selectNoneAction
= new AbstractAction("&None") {
45 public void actionPerformed(ActionEvent e
) {
50 return new Action
[]{selectNoneAction
, getOKAction(), getCancelAction()};
54 protected void doOKAction() {
55 SimpleNode node
= getSelectedNode();
56 if (node
instanceof NullNode
) node
= null;
59 if (!(node
instanceof MavenProjectsStructure
.ProjectNode
)) {
60 ((MavenProjectsStructure
.CustomNode
)node
).getParent(MavenProjectsStructure
.ProjectNode
.class);
63 myResult
= node
!= null ?
((MavenProjectsStructure
.ProjectNode
)node
).getMavenProject() : null;
68 public MavenProject
getResult() {