update copyright
[fedora-idea.git] / java / idea-ui / src / com / intellij / facet / impl / ui / libraries / LibrariesValidationComponentImpl.java
blobf733ee52e1c82e6d1c491059787cef966a1695d2
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.
17 package com.intellij.facet.impl.ui.libraries;
19 import com.intellij.facet.impl.ui.FacetErrorPanel;
20 import com.intellij.facet.ui.libraries.LibrariesValidationComponent;
21 import com.intellij.facet.ui.libraries.FacetLibrariesValidatorDescription;
22 import com.intellij.facet.ui.libraries.LibraryInfo;
23 import com.intellij.openapi.module.Module;
24 import com.intellij.util.EventDispatcher;
26 import javax.swing.*;
28 /**
29 * @author nik
31 public class LibrariesValidationComponentImpl implements LibrariesValidationComponent {
32 private final EventDispatcher<ValidityListener> myDispatcher = EventDispatcher.create(ValidityListener.class);
33 private final FacetErrorPanel myErrorPanel;
34 private final FacetLibrariesValidatorImpl myLibrariesValidator;
35 private final Module myModule;
37 public LibrariesValidationComponentImpl(LibraryInfo[] requiredLibraries, final Module module, String defaultLibraryName) {
38 myErrorPanel = new FacetErrorPanel();
39 FacetLibrariesValidatorDescription description = new FacetLibrariesValidatorDescription(defaultLibraryName);
40 myModule = module;
41 myLibrariesValidator = new FacetLibrariesValidatorImpl(requiredLibraries, description, new LibrariesValidatorContextImpl(myModule),
42 myErrorPanel.getValidatorsManager());
43 myErrorPanel.getValidatorsManager().registerValidator(myLibrariesValidator);
44 myErrorPanel.addListener(new Runnable() {
45 public void run() {
46 myDispatcher.getMulticaster().valididyChanged(myErrorPanel.isOk());
48 });
51 public JComponent getComponent() {
52 return myErrorPanel.getComponent();
55 public void validate() {
56 myErrorPanel.getValidatorsManager().validate();
59 public boolean isValid() {
60 return myErrorPanel.isOk();
63 public void addValidityListener(final ValidityListener listener) {
64 myDispatcher.addListener(listener);
67 public void removeValidityListener(final ValidityListener listener) {
68 myDispatcher.removeListener(listener);
71 public void setupLibraries() {