update copyright
[fedora-idea.git] / java / idea-ui / src / com / intellij / ide / util / importProject / ModulesLayoutPanel.java
blobbbcf40401cbd4e16da957d7aa9919488f1641d81
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.util.importProject;
18 import org.jetbrains.annotations.Nullable;
20 import java.io.File;
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.Collections;
24 import java.util.List;
26 /**
27 * @author Eugene Zhuravlev
28 * Date: Jul 16, 2007
30 public class ModulesLayoutPanel extends ProjectLayoutPanel<ModuleDescriptor>{
31 private final LibraryFilter myLibrariesFilter;
33 public static interface LibraryFilter {
34 boolean isLibraryChosen(LibraryDescriptor libDescriptor);
36 public ModulesLayoutPanel(ModuleInsight insight, final LibraryFilter libFilter) {
37 super(insight);
38 myLibrariesFilter = libFilter;
41 protected String getElementName(final ModuleDescriptor entry) {
42 return entry.getName();
45 protected void setElementName(final ModuleDescriptor entry, final String name) {
46 entry.setName(name);
49 protected List<ModuleDescriptor> getEntries() {
50 final List<ModuleDescriptor> modules = getInsight().getSuggestedModules();
51 return modules != null? modules : Collections.<ModuleDescriptor>emptyList();
54 protected Collection getDependencies(final ModuleDescriptor entry) {
55 final List deps = new ArrayList();
56 deps.addAll(entry.getDependencies());
57 final Collection<LibraryDescriptor> libDependencies = getInsight().getLibraryDependencies(entry);
58 for (LibraryDescriptor libDependency : libDependencies) {
59 if (myLibrariesFilter.isLibraryChosen(libDependency)) {
60 deps.add(libDependency);
63 return deps;
66 @Nullable
67 protected ModuleDescriptor merge(final List<ModuleDescriptor> entries) {
68 final ModuleInsight insight = getInsight();
69 ModuleDescriptor mainDescr = null;
70 for (ModuleDescriptor entry : entries) {
71 if (mainDescr == null) {
72 mainDescr = entry;
74 else {
75 insight.merge(mainDescr, entry);
78 return mainDescr;
81 protected ModuleDescriptor split(final ModuleDescriptor entry, final String newEntryName, final Collection<File> extractedData) {
82 return getInsight().splitModule(entry, newEntryName, extractedData);
85 protected Collection<File> getContent(final ModuleDescriptor entry) {
86 return entry.getContentRoots();
89 protected String getEntriesChooserTitle() {
90 return "Modules";
93 protected String getDependenciesTitle() {
94 return "Module dependencies";
97 protected String getSplitDialogTitle() {
98 return "Split Module";
101 protected String getSplitDialogChooseFilesPrompt() {
102 return "Select content roots to extract to the new module:";
105 protected String getNameAlreadyUsedMessage(final String name) {
106 return "Module with name " + name + " already exists";
109 protected String getStepDescriptionText() {
110 return "Please review suggested module structure for the project. At this stage you may set module names,\n" +
111 "exclude particular modules from the project, merge or split individual modules.\n" +
112 "All dependencies between the modules as well as dependencies on the libraries will be automatically updated.";