find usages & validation in project structure reworked
[fedora-idea.git] / java / idea-ui / src / com / intellij / openapi / roots / ui / configuration / projectRoot / JdkConfigurable.java
blob4f2ff5c95c4b4cf99f59503230c32181625aa10f
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.openapi.roots.ui.configuration.projectRoot;
19 import com.intellij.openapi.options.ConfigurationException;
20 import com.intellij.openapi.project.Project;
21 import com.intellij.openapi.project.ProjectBundle;
22 import com.intellij.openapi.projectRoots.Sdk;
23 import com.intellij.openapi.projectRoots.impl.ProjectJdkImpl;
24 import com.intellij.openapi.projectRoots.ui.SdkEditor;
25 import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement;
26 import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.SdkProjectStructureElement;
27 import com.intellij.openapi.util.ActionCallback;
28 import com.intellij.ui.navigation.History;
29 import com.intellij.ui.navigation.Place;
30 import org.jetbrains.annotations.NonNls;
31 import org.jetbrains.annotations.NotNull;
32 import org.jetbrains.annotations.Nullable;
34 import javax.swing.*;
36 /**
37 * User: anna
38 * Date: 05-Jun-2006
40 public class JdkConfigurable extends ProjectStructureElementConfigurable<Sdk> implements Place.Navigator {
41 private final ProjectJdkImpl myProjectJdk;
42 private final SdkEditor mySdkEditor;
43 private SdkProjectStructureElement myProjectStructureElement;
45 public JdkConfigurable(final ProjectJdkImpl projectJdk,
46 final ProjectJdksModel configurable,
47 final Runnable updateTree, @NotNull History history, Project project) {
48 super(true, updateTree);
49 myProjectJdk = projectJdk;
50 mySdkEditor = new SdkEditor(configurable, history, myProjectJdk);
51 final StructureConfigurableContext context = ModuleStructureConfigurable.getInstance(project).getContext();
52 myProjectStructureElement = new SdkProjectStructureElement(context, myProjectJdk);
55 @Override
56 public ProjectStructureElement getProjectStructureElement() {
57 return myProjectStructureElement;
60 public void setDisplayName(final String name) {
61 myProjectJdk.setName(name);
64 public Sdk getEditableObject() {
65 return myProjectJdk;
68 public String getBannerSlogan() {
69 return ProjectBundle.message("project.roots.jdk.banner.text", myProjectJdk.getName());
72 public String getDisplayName() {
73 return myProjectJdk.getName();
76 public Icon getIcon() {
77 return myProjectJdk.getSdkType().getIcon();
80 @Nullable
81 @NonNls
82 public String getHelpTopic() {
83 return "preferences.jdks";
87 public JComponent createOptionsPanel() {
88 return mySdkEditor.createComponent();
91 public boolean isModified() {
92 return mySdkEditor.isModified();
95 public void apply() throws ConfigurationException {
96 mySdkEditor.apply();
99 public void reset() {
100 mySdkEditor.reset();
103 public void disposeUIResources() {
104 mySdkEditor.disposeUIResources();
107 public void setHistory(final History history) {
110 public ActionCallback navigateTo(@Nullable final Place place, final boolean requestFocus) {
111 return mySdkEditor.navigateTo(place, requestFocus);
114 public void queryPlace(@NotNull final Place place) {
115 mySdkEditor.queryPlace(place);