merge supported extensions
[fedora-idea.git] / java / idea-ui / src / com / intellij / ide / actions / OpenProjectAction.java
blob4b8d1ce8e1cddd712edd03b19cbc765a510b8eb8
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.intellij.ide.actions;
18 import com.intellij.ide.IdeBundle;
19 import com.intellij.ide.highlighter.ProjectFileType;
20 import com.intellij.ide.impl.ProjectUtil;
21 import com.intellij.openapi.actionSystem.AnAction;
22 import com.intellij.openapi.actionSystem.AnActionEvent;
23 import com.intellij.openapi.actionSystem.PlatformDataKeys;
24 import com.intellij.openapi.extensions.Extensions;
25 import com.intellij.openapi.fileChooser.FileChooser;
26 import com.intellij.openapi.fileChooser.FileChooserDescriptor;
27 import com.intellij.openapi.project.DumbAware;
28 import com.intellij.openapi.project.Project;
29 import com.intellij.openapi.util.text.StringUtil;
30 import com.intellij.openapi.vfs.VirtualFile;
31 import com.intellij.projectImport.ProjectOpenProcessor;
32 import com.intellij.projectImport.ProjectOpenProcessorBase;
34 import java.util.Collections;
35 import java.util.HashSet;
36 import java.util.Set;
38 public class OpenProjectAction extends AnAction implements DumbAware {
39 public void actionPerformed(AnActionEvent e) {
40 final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
42 final FileChooserDescriptor descriptor = new OpenProjectFileChooserDescriptor(true);
43 descriptor.setTitle(IdeBundle.message("title.open.project"));
44 final Set<String> extensions = new HashSet<String>();
45 extensions.add(ProjectFileType.DOT_DEFAULT_EXTENSION);
46 final ProjectOpenProcessor[] openProcessors = Extensions.getExtensions(ProjectOpenProcessorBase.EXTENSION_POINT_NAME);
47 for (ProjectOpenProcessor openProcessor : openProcessors) {
48 final String[] supportedExtensions = ((ProjectOpenProcessorBase)openProcessor).getSupportedExtensions();
49 if (supportedExtensions != null) {
50 Collections.addAll(extensions, supportedExtensions);
53 descriptor.setDescription(IdeBundle.message("filter.project.files", StringUtil.join(extensions, ", ")));
54 final VirtualFile[] files = FileChooser.chooseFiles(project, descriptor);
56 if (files.length == 0 || files[0] == null) return;
58 ProjectUtil.openOrImport(files[0].getPath(), project, false);