Search in sources :

Example 1 with PlainDocument

use of javax.swing.text.PlainDocument in project GCViewer by chewiebug.

the class AutoCompletionTextField method createDefaultModel.

protected Document createDefaultModel() {
    return new PlainDocument() {

        public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
            final String text = this.getText(0, offs) + str;
            List oldSuggestions = suggestions;
            suggestions = recentResourceNamesModel.getResourceNamesStartingWith(text);
            String appendString = "";
            if (!suggestions.isEmpty()) {
                final String suggestion = (String) suggestions.get(0);
                appendString = suggestion.substring(text.length());
            }
            super.insertString(offs, str + appendString, a);
            setCaretPosition(offs);
            setSelectionStart(text.length());
            setSelectionEnd(getLength());
            if (!oldSuggestions.equals(suggestions)) {
                comboBoxModel.fireContentsChanged();
            }
        }

        public void remove(int offs, int len) throws BadLocationException {
            super.remove(offs, len);
            final List oldSuggestions = suggestions;
            suggestions = recentResourceNamesModel.getResourceNamesStartingWith(AutoCompletionTextField.this.getText());
            if (!oldSuggestions.equals(suggestions)) {
                comboBoxModel.fireContentsChanged();
            }
        }
    };
}
Also used : AttributeSet(javax.swing.text.AttributeSet) List(java.util.List) ArrayList(java.util.ArrayList) PlainDocument(javax.swing.text.PlainDocument)

Example 2 with PlainDocument

use of javax.swing.text.PlainDocument in project intellij-community by JetBrains.

the class JUnitConfigurable method installDocuments.

private void installDocuments() {
    for (int i = 0; i < myTestLocations.length; i++) {
        final LabeledComponent testLocation = getTestLocation(i);
        final JComponent component = testLocation.getComponent();
        final ComponentWithBrowseButton field;
        Object document;
        if (component instanceof TextFieldWithBrowseButton) {
            field = (TextFieldWithBrowseButton) component;
            document = new PlainDocument();
            ((TextFieldWithBrowseButton) field).getTextField().setDocument((Document) document);
        } else if (component instanceof EditorTextFieldWithBrowseButton) {
            field = (ComponentWithBrowseButton) component;
            document = ((EditorTextField) field.getChildComponent()).getDocument();
        } else {
            field = myPatternTextField;
            document = new PlainDocument();
            ((TextFieldWithBrowseButton) field).getTextField().setDocument((Document) document);
        }
        myBrowsers[i].setField(field);
        if (myBrowsers[i] instanceof MethodBrowser) {
            final EditorTextField childComponent = (EditorTextField) field.getChildComponent();
            ((MethodBrowser) myBrowsers[i]).installCompletion(childComponent);
            document = childComponent.getDocument();
        }
        myModel.setJUnitDocument(i, document);
    }
}
Also used : MethodBrowser(com.intellij.execution.MethodBrowser) PlainDocument(javax.swing.text.PlainDocument) PlainDocument(javax.swing.text.PlainDocument) Document(javax.swing.text.Document)

Example 3 with PlainDocument

use of javax.swing.text.PlainDocument in project intellij-community by JetBrains.

the class StepicStudyOptions method createUIComponents.

private void createUIComponents() {
    Document doc = new PlainDocument();
    myPasswordField = new JPasswordField(doc, null, 0);
}
Also used : PlainDocument(javax.swing.text.PlainDocument) Document(javax.swing.text.Document) PlainDocument(javax.swing.text.PlainDocument)

Aggregations

PlainDocument (javax.swing.text.PlainDocument)3 Document (javax.swing.text.Document)2 MethodBrowser (com.intellij.execution.MethodBrowser)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AttributeSet (javax.swing.text.AttributeSet)1