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
.plugins
.groovy
.config
;
18 import com
.intellij
.openapi
.roots
.OrderRootType
;
19 import com
.intellij
.openapi
.roots
.libraries
.Library
;
20 import com
.intellij
.openapi
.roots
.ui
.configuration
.projectRoot
.LibrariesContainer
;
21 import com
.intellij
.openapi
.vfs
.VfsUtil
;
22 import com
.intellij
.openapi
.vfs
.VirtualFile
;
23 import org
.jetbrains
.annotations
.Nls
;
24 import org
.jetbrains
.annotations
.NotNull
;
25 import org
.jetbrains
.plugins
.groovy
.GroovyIcons
;
26 import org
.jetbrains
.plugins
.groovy
.util
.LibrariesUtil
;
34 public class GroovyLibraryManager
extends AbstractGroovyLibraryManager
{
35 public boolean managesLibrary(@NotNull Library library
, LibrariesContainer container
) {
36 return GroovyConfigUtils
.isGroovyLibrary(container
.getLibraryFiles(library
, OrderRootType
.CLASSES
));
40 public String
getLibraryVersion(@NotNull Library library
, LibrariesContainer librariesContainer
) {
41 return GroovyConfigUtils
.getInstance().getSDKVersion(LibrariesUtil
.getGroovyLibraryHome(librariesContainer
.getLibraryFiles(library
, OrderRootType
.CLASSES
)));
45 public Icon
getIcon() {
46 return GroovyIcons
.GROOVY_ICON_16x16
;
51 public String
getAddActionText() {
52 return "Create new Groovy SDK...";
56 public boolean isSDKHome(@NotNull VirtualFile file
) {
57 return GroovyConfigUtils
.getInstance().isSDKHome(file
);
61 protected void fillLibrary(String path
, Library
.ModifiableModel model
) {
62 File srcRoot
= new File(path
+ "/src/main");
63 if (srcRoot
.exists()) {
64 model
.addRoot(VfsUtil
.getUrlForLibraryRoot(srcRoot
), OrderRootType
.SOURCES
);
68 File libDir
= new File(path
+ "/lib");
69 if (libDir
.exists()) {
70 jars
= libDir
.listFiles();
72 jars
= new File(path
+ "/embeddable").listFiles();
75 for (File file
: jars
) {
76 if (file
.getName().endsWith(".jar")) {
77 model
.addRoot(VfsUtil
.getUrlForLibraryRoot(file
), OrderRootType
.CLASSES
);
85 public String
getSDKVersion(String path
) {
86 return GroovyConfigUtils
.getInstance().getSDKVersion(path
);
90 public Icon
getDialogIcon() {
91 return GroovyIcons
.GROOVY_ICON_32x32
;
97 public String
getLibraryCategoryName() {