NPE (18686)
[fedora-idea.git] / platform / lang-impl / src / com / intellij / ui / EditorComboWithBrowseButton.java
blobf55e55aea575fc96b011037972ee106e9f1104b9
1 /*
2 * Copyright 2000-2010 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.ui;
18 import com.intellij.openapi.fileTypes.StdFileTypes;
19 import com.intellij.openapi.project.Project;
20 import com.intellij.openapi.ui.ComponentWithBrowseButton;
21 import com.intellij.util.ArrayUtil;
22 import org.jetbrains.annotations.NotNull;
24 import java.awt.event.ActionListener;
25 import java.util.List;
27 /**
28 * @author ven
30 public class EditorComboWithBrowseButton extends ComponentWithBrowseButton<EditorComboBox> implements TextAccessor {
31 public EditorComboWithBrowseButton(final ActionListener browseActionListener,
32 final String text,
33 @NotNull final Project project,
34 final String recentsKey) {
35 super(new EditorComboBox(text, project, StdFileTypes.PLAIN_TEXT), browseActionListener);
36 final List<String> recentEntries = RecentsManager.getInstance(project).getRecentEntries(recentsKey);
37 if (recentEntries != null) {
38 setHistory(ArrayUtil.toStringArray(recentEntries));
40 if (text != null && text.length() > 0) {
41 prependItem(text);
45 public String getText() {
46 return getChildComponent().getText().trim();
49 public void setText(final String text) {
50 getChildComponent().setText(text);
53 public boolean isEditable() {
54 return !getChildComponent().getEditorEx().isViewer();
57 public void setHistory(String[] history) {
58 getChildComponent().setHistory(history);
61 public void prependItem(String item) {
62 getChildComponent().prependItem(item);