mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-68253 Issue trackers integration. Completion in TextFields.
This commit is contained in:
@@ -52,13 +52,13 @@ public class TextFieldWithAutoCompletion<T> extends LanguageTextField {
|
||||
|
||||
public TextFieldWithAutoCompletion() {
|
||||
// For UI designer
|
||||
this(null, null, false);
|
||||
this(null, null, false, null);
|
||||
}
|
||||
|
||||
public TextFieldWithAutoCompletion(final Project project,
|
||||
@Nullable final TextFieldWithAutoCompletionListProvider<T> provider,
|
||||
final boolean showAutocompletionIsAvailableHint) {
|
||||
super(PlainTextLanguage.INSTANCE, project, "");
|
||||
final boolean showAutocompletionIsAvailableHint, @Nullable final String text) {
|
||||
super(PlainTextLanguage.INSTANCE, project, text == null ? "" : text);
|
||||
|
||||
myShowAutocompletionIsAvailableHint = showAutocompletionIsAvailableHint;
|
||||
|
||||
@@ -70,8 +70,9 @@ public class TextFieldWithAutoCompletion<T> extends LanguageTextField {
|
||||
public static TextFieldWithAutoCompletion<String> create(final Project project,
|
||||
@NotNull final Collection<String> items,
|
||||
@Nullable final Icon icon,
|
||||
final boolean showAutocompletionIsAvailableHint) {
|
||||
return new TextFieldWithAutoCompletion<String>(project, new StringsCompletionProvider(items, icon), showAutocompletionIsAvailableHint);
|
||||
final boolean showAutocompletionIsAvailableHint, @Nullable final String text) {
|
||||
return new TextFieldWithAutoCompletion<String>(project, new StringsCompletionProvider(items, icon), showAutocompletionIsAvailableHint,
|
||||
text);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -246,7 +246,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
}
|
||||
}
|
||||
|
||||
public void setText(final String text) {
|
||||
public void setText(@NotNull final String text) {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ public class AndroidCreateLayoutFileAction extends CreateTypedResourceFileAction
|
||||
setTitle(AndroidBundle.message("new.typed.resource.dialog.title", "Layout"));
|
||||
final List<String> tagNames = getSortedAllowedTagNames(facet);
|
||||
myRootElementField = new TextFieldWithAutoCompletion<String>(
|
||||
facet.getModule().getProject(), new TextFieldWithAutoCompletion.StringsCompletionProvider(tagNames, null), true);
|
||||
facet.getModule().getProject(), new TextFieldWithAutoCompletion.StringsCompletionProvider(tagNames, null), true, null);
|
||||
myRootElementField.setText(myDefaultRootTag);
|
||||
myRootElementFieldWrapper.add(myRootElementField, BorderLayout.CENTER);
|
||||
myRootElementLabel.setLabelFor(myRootElementField);
|
||||
|
||||
@@ -213,7 +213,7 @@ public class CreateResourceFileDialog extends DialogWrapper {
|
||||
if (action != null) {
|
||||
final List<String> allowedTagNames = action.getSortedAllowedTagNames(myFacet);
|
||||
myRootElementField = new TextFieldWithAutoCompletion<String>(
|
||||
myFacet.getModule().getProject(), new TextFieldWithAutoCompletion.StringsCompletionProvider(allowedTagNames, null), true);
|
||||
myFacet.getModule().getProject(), new TextFieldWithAutoCompletion.StringsCompletionProvider(allowedTagNames, null), true, null);
|
||||
myRootElementField.setEnabled(allowedTagNames.size() > 1);
|
||||
myRootElementField.setText(!action.isChooseTagName() && myPredefinedResourceType != ResourceType.LAYOUT
|
||||
? action.getDefaultRootTag()
|
||||
|
||||
@@ -77,7 +77,7 @@ class EditLogFilterDialog extends DialogWrapper {
|
||||
setItems(Arrays.asList(myUsedTags));
|
||||
return super.getItems(prefix, cached, parameters);
|
||||
}
|
||||
}, true);
|
||||
}, true, null);
|
||||
|
||||
myTagFieldWrapper.add(myTagField);
|
||||
myLogTagLabel.setLabelFor(myTagField);
|
||||
@@ -97,7 +97,7 @@ class EditLogFilterDialog extends DialogWrapper {
|
||||
final int pid2 = Integer.parseInt(item2);
|
||||
return Comparing.compare(pid1, pid2);
|
||||
}
|
||||
}, true);
|
||||
}, true, null);
|
||||
myPidFieldWrapper.add(myPidField);
|
||||
|
||||
myLogLevelCombo.setModel(new EnumComboBoxModel<Log.LogLevel>(Log.LogLevel.class));
|
||||
|
||||
@@ -67,6 +67,7 @@ public class BaseRepositoryEditor<T extends BaseRepository> extends TaskReposito
|
||||
protected JBCheckBox myLoginAnonymouslyJBCheckBox;
|
||||
|
||||
private boolean myApplying;
|
||||
protected Project myProject;
|
||||
protected final T myRepository;
|
||||
private final Consumer<T> myChangeListener;
|
||||
private final Document myDocument;
|
||||
@@ -74,6 +75,7 @@ public class BaseRepositoryEditor<T extends BaseRepository> extends TaskReposito
|
||||
private JComponent myAnchor;
|
||||
|
||||
public BaseRepositoryEditor(final Project project, final T repository, Consumer<T> changeListener) {
|
||||
myProject = project;
|
||||
myRepository = repository;
|
||||
myChangeListener = changeListener;
|
||||
|
||||
@@ -115,12 +117,7 @@ public class BaseRepositoryEditor<T extends BaseRepository> extends TaskReposito
|
||||
myComment.setText("Available placeholders: " + repository.getComment());
|
||||
|
||||
installListener(myAddCommitMessage);
|
||||
myDocument.addDocumentListener(new com.intellij.openapi.editor.event.DocumentAdapter() {
|
||||
@Override
|
||||
public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent e) {
|
||||
doApply();
|
||||
}
|
||||
});
|
||||
installListener(myDocument);
|
||||
|
||||
installListener(myURLText);
|
||||
installListener(myUserNameText);
|
||||
@@ -194,6 +191,15 @@ public class BaseRepositoryEditor<T extends BaseRepository> extends TaskReposito
|
||||
});
|
||||
}
|
||||
|
||||
protected void installListener(final Document document) {
|
||||
document.addDocumentListener(new com.intellij.openapi.editor.event.DocumentAdapter() {
|
||||
@Override
|
||||
public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent e) {
|
||||
doApply();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void doApply() {
|
||||
if (!myApplying) {
|
||||
try {
|
||||
|
||||
@@ -88,7 +88,7 @@ public class OpenTaskDialog extends DialogWrapper {
|
||||
mySelectedTask = task;
|
||||
taskChanged();
|
||||
}
|
||||
}, false);
|
||||
}, false, null);
|
||||
myEditorPanel.add(myTaskName);
|
||||
myTaskName.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -21,7 +22,7 @@ import java.util.regex.Pattern;
|
||||
* User: Evgeny.Zakrevsky
|
||||
* Date: 10/4/12
|
||||
*/
|
||||
@Tag("Web")
|
||||
@Tag("Generic")
|
||||
public class GenericWebRepository extends BaseRepositoryImpl {
|
||||
private String myTasksListURL;
|
||||
private String myTaskPattern;
|
||||
@@ -131,16 +132,18 @@ public class GenericWebRepository extends BaseRepositoryImpl {
|
||||
return new GenericWebRepository(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getTasksListURL() {
|
||||
return myTasksListURL;
|
||||
return myTasksListURL == null ? "" : myTasksListURL;
|
||||
}
|
||||
|
||||
public void setTasksListURL(final String tasksListURL) {
|
||||
myTasksListURL = tasksListURL;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getTaskPattern() {
|
||||
return myTaskPattern;
|
||||
return myTaskPattern == null ? "" : myTaskPattern;
|
||||
}
|
||||
|
||||
public void setTaskPattern(final String taskPattern) {
|
||||
@@ -175,8 +178,9 @@ public class GenericWebRepository extends BaseRepositoryImpl {
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getLoginURL() {
|
||||
return myLoginURL;
|
||||
return myLoginURL == null ? "" : myLoginURL;
|
||||
}
|
||||
|
||||
public void setLoginURL(final String loginURL) {
|
||||
|
||||
+45
-15
@@ -1,14 +1,22 @@
|
||||
package com.intellij.tasks.generic;
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.tasks.config.BaseRepositoryEditor;
|
||||
import com.intellij.ui.TextFieldWithAutoCompletion;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.FormBuilder;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.intellij.tasks.generic.GenericWebRepository.*;
|
||||
|
||||
/**
|
||||
* User: Evgeny.Zakrevsky
|
||||
* Date: 10/4/12
|
||||
@@ -16,10 +24,10 @@ import javax.swing.*;
|
||||
public class GenericWebRepositoryEditor extends BaseRepositoryEditor<GenericWebRepository> {
|
||||
private JBLabel myTasksListURLLabel;
|
||||
private JBLabel myTaskPatternLabel;
|
||||
private JTextField myTasksListURLText;
|
||||
private JTextField myTaskPatternText;
|
||||
private TextFieldWithAutoCompletion<String> myTasksListURLText;
|
||||
private TextFieldWithAutoCompletion<String> myTaskPatternText;
|
||||
private JBLabel myLoginURLLabel;
|
||||
private JTextField myLoginURLText;
|
||||
private TextFieldWithAutoCompletion<String> myLoginURLText;
|
||||
|
||||
public GenericWebRepositoryEditor(final Project project,
|
||||
final GenericWebRepository repository,
|
||||
@@ -48,26 +56,48 @@ public class GenericWebRepositoryEditor extends BaseRepositoryEditor<GenericWebR
|
||||
@Nullable
|
||||
@Override
|
||||
protected JComponent createCustomPanel() {
|
||||
myTasksListURLLabel = new JBLabel("Tasks List URL:", SwingConstants.RIGHT);
|
||||
myTasksListURLText = new JTextField(myRepository.getTasksListURL());
|
||||
installListener(myTasksListURLText);
|
||||
myTaskPatternLabel = new JBLabel("Task Pattern:", SwingConstants.RIGHT);
|
||||
myTaskPatternText = new JTextField(myRepository.getTaskPattern());
|
||||
installListener(myTaskPatternText);
|
||||
myLoginURLLabel = new JBLabel("Login URL:", SwingConstants.RIGHT);
|
||||
myLoginURLText = new JTextField(myRepository.getLoginURL());
|
||||
installListener(myLoginURLText);
|
||||
myLoginURLText = TextFieldWithAutoCompletion
|
||||
.create(myProject, ContainerUtil.newArrayList(SERVER_URL_PLACEHOLDER, USERNAME_PLACEHOLDER, PASSWORD_PLACEHOLDER), null, false,
|
||||
myRepository.getLoginURL());
|
||||
installListener(myLoginURLText.getDocument());
|
||||
|
||||
myTasksListURLLabel = new JBLabel("Tasks List URL:", SwingConstants.RIGHT);
|
||||
myTasksListURLText = TextFieldWithAutoCompletion.create(myProject, ContainerUtil.newArrayList(SERVER_URL_PLACEHOLDER), null, false,
|
||||
myRepository.getTasksListURL());
|
||||
installListener(myTasksListURLText.getDocument());
|
||||
|
||||
myTaskPatternLabel = new JBLabel("Task Pattern:", SwingConstants.RIGHT);
|
||||
myTaskPatternText =
|
||||
TextFieldWithAutoCompletion
|
||||
.create(myProject, ContainerUtil.newArrayList("({id}.+?)", "({summary}.+?)"), null, false, myRepository.getTaskPattern());
|
||||
installListener(myTaskPatternText.getDocument());
|
||||
|
||||
String useCompletionText = ". Use " +
|
||||
KeymapUtil
|
||||
.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)) +
|
||||
" for completion.";
|
||||
|
||||
return FormBuilder.createFormBuilder().setAlignLabelOnRight(true)
|
||||
.addLabeledComponent(myLoginURLLabel, myLoginURLText)
|
||||
.addTooltip("Available placeholders: " + GenericWebRepository.SERVER_URL_PLACEHOLDER + ", " +
|
||||
GenericWebRepository.USERNAME_PLACEHOLDER + ", " + GenericWebRepository.PASSWORD_PLACEHOLDER)
|
||||
.addTooltip(
|
||||
"Available placeholders: " + SERVER_URL_PLACEHOLDER + ", " + USERNAME_PLACEHOLDER + ", " + PASSWORD_PLACEHOLDER + useCompletionText)
|
||||
.addLabeledComponent(myTasksListURLLabel, myTasksListURLText)
|
||||
.addTooltip("Available placeholders: " + GenericWebRepository.SERVER_URL_PLACEHOLDER)
|
||||
.addTooltip("Available placeholders: " + SERVER_URL_PLACEHOLDER + useCompletionText)
|
||||
.addLabeledComponent(myTaskPatternLabel, myTaskPatternText)
|
||||
.addTooltip("Task pattern should be a regexp with two matching group: ({id}.+?) and ({summary}.+?)")
|
||||
.addTooltip("Task pattern should be a regexp with two matching group: ({id}.+?) and ({summary}.+?)" + useCompletionText)
|
||||
.getPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
if (myTasksListURLText != null && myTasksListURLText.getEditor() != null)
|
||||
EditorFactory.getInstance().releaseEditor(myTasksListURLText.getEditor());
|
||||
if (myLoginURLText.getEditor() != null) EditorFactory.getInstance().releaseEditor(myLoginURLText.getEditor());
|
||||
if (myTaskPatternText.getEditor() != null) EditorFactory.getInstance().releaseEditor(myTaskPatternText.getEditor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnchor(@Nullable final JComponent anchor) {
|
||||
super.setAnchor(anchor);
|
||||
|
||||
@@ -44,7 +44,7 @@ public class HtmlLanguageLevelForm {
|
||||
|
||||
public HtmlLanguageLevelForm(Project project) {
|
||||
final String[] urls = ExternalResourceManager.getInstance().getResourceUrls(null, true);
|
||||
myDoctypeTextField = TextFieldWithAutoCompletion.create(project, Arrays.asList(urls), null, true);
|
||||
myDoctypeTextField = TextFieldWithAutoCompletion.create(project, Arrays.asList(urls), null, true, null);
|
||||
myOtherDoctypeWrapper.add(myDoctypeTextField);
|
||||
ActionListener listener = new ActionListener() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user