Java 类javax.swing.event.DocumentEvent 实例源码

项目:incubator-netbeans    文件:FoldHierarchyTransactionImpl.java   
/**
 * This method implements the <code>DocumentListener</code>.
 * <br>
 * It is not intended to be called by clients.
 */
public void insertUpdate(DocumentEvent evt) {
    // Check whether there was an insert done right
    // at the original ending offset of the fold
    // so the fold end offset should be moved back.
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("insertUpdate: offset=" + evt.getOffset() // NOI18N
            + ", length=" + evt.getLength() + '\n'); // NOI18N
    }
    try {
        if (FoldHierarchyExecution.isEventInUndoRedoHack(evt)) {
            validateAffectedFolds(execution.getRootFold(), evt);
        }

        insertCheckEndOffset(execution.getRootFold(), evt);

    } catch (BadLocationException e) {
        ErrorManager.getDefault().notify(e);
    }
}
项目:incubator-netbeans    文件:PanelProjectLocationVisual.java   
/** Handles changes in the Project name and project directory
 */
private void updateTexts(DocumentEvent e) {
    Document doc = e.getDocument();
    if (doc.equals(projectNameTextField.getDocument()) || doc.equals(projectLocationTextField.getDocument())) {
        // Change in the project name
        String projectName = projectNameTextField.getText();
        String projectFolder = projectLocationTextField.getText();
        String projFolderPath = FileUtil.normalizeFile(new File(projectFolder)).getAbsolutePath();
        if (projFolderPath.endsWith(File.separator)) {
            createdFolderTextField.setText(projFolderPath + projectName);
        } else {
            createdFolderTextField.setText(projFolderPath + File.separator + projectName);
        }
    }

    panel.fireChangeEvent(); // Notify that the panel changed        

    if (this.projectNameTextField.getDocument().equals(e.getDocument())) {
        firePropertyChange(PROP_PROJECT_NAME, null, this.projectNameTextField.getText());
    }
    if (this.projectLocationTextField.getDocument().equals(e.getDocument())) {
        firePropertyChange(PROP_PROJECT_LOCATION, null, this.projectLocationTextField.getText());
    }
}
项目:incubator-netbeans    文件:BasicBrandingPanel.java   
public BasicBrandingPanel(BrandingModel model) {
    super(NbBundle.getMessage(BasicBrandingPanel.class, "LBL_BasicTab"), model); //NOI18N
    initComponents();        
    refresh(); 
    checkValidity();
    DocumentListener textFieldChangeListener = new UIUtil.DocumentAdapter() {
        @Override
        public void insertUpdate(DocumentEvent e) {
            checkValidity();
            setModified();
            titleValueModified = true;
        }
    };
    titleValue.getDocument().addDocumentListener(textFieldChangeListener);
    titleValueModified = false;
}
项目:incubator-netbeans    文件:SetUpRemotePlatform.java   
private void updateDefaultDirectory(DocumentEvent e) {
    Document doc = e.getDocument();
    if (doc.equals(username.getDocument())) {
        String usernameText = username.getText();
        if (!usernameText.isEmpty()) {
            String workdirText = workingDir.getText();
            if (workdirText.isEmpty() || (currentDefaultWorkDir != null && workdirText.equals(currentDefaultWorkDir))) {
                String updatedDefaultworkDir = "/home/" + usernameText + "/NetBeansProjects/"; //NOI18N
                workingDir.setText(updatedDefaultworkDir);
                currentDefaultWorkDir = updatedDefaultworkDir;
            }
        } else {
            if (currentDefaultWorkDir != null && workingDir.getText().equals(currentDefaultWorkDir)) {
                workingDir.setText(""); //NOI18N
                currentDefaultWorkDir = null;
            }
        }
    }
}
项目:educational-plugin    文件:StudyTwitterUtils.java   
/**
 * Listener updates label indicating remaining symbols number like in twitter.
 */
private static DocumentListener createTextFieldLengthDocumentListener(@NotNull TwitterDialogWrapper builder, @NotNull final StudyTwitterUtils.TwitterDialogPanel panel) {
  return new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      int length = e.getDocument().getLength();
      if (length > 140 || length == 0) {
        builder.setOKActionEnabled(false);
        panel.getRemainSymbolsLabel().setText("<html><font color='red'>" + String.valueOf(140 - length) + "</font></html>");
      } else {
        builder.setOKActionEnabled(true);
        panel.getRemainSymbolsLabel().setText(String.valueOf(140 - length));
      }

    }
  };
}
项目:incubator-netbeans    文件:BaseTextUI.java   
/** Remove from document notification. */
    public void removeUpdate(DocumentEvent evt) {
        checkLengthyAtomicEdit(evt);
        // No longer trigger syntax update related repaint
//        try {
//            BaseDocumentEvent bevt = (BaseDocumentEvent)evt;
//            EditorUI eui = getEditorUI();
//            int y = getYFromPos(evt.getOffset());
//            int lineHeight = eui.getLineHeight();
//            int syntaxY = getYFromPos(bevt.getSyntaxUpdateOffset());
//            // !!! patch for case when DocMarksOp.eolMark is at the end of document
//            if (bevt.getSyntaxUpdateOffset() == evt.getDocument().getLength()) {
//                syntaxY += lineHeight;
//            }
//            if (getComponent().isShowing()) {
//                eui.repaint(y, Math.max(lineHeight, syntaxY - y));
//            }
//
//        } catch (BadLocationException ex) {
//            Utilities.annotateLoggable(ex);
//        }
    }
项目:AntIDE    文件:OutputFrame.java   
/**
 *  ȭ���� ������ �ٲ� Ouput�� ���̰� ��ȯ�Ѵ�.
 */
private void changeTab( DocumentEvent e ) {
    if ( e.getDocument() == outputStd.getOutput().getDocument() ) {
        if ( tabPane.getSelectedComponent() != outputStd )
            tabPane.setSelectedComponent(outputStd);
    } else if ( e.getDocument() == outputErr.getOutput().getDocument() ) {
        if ( tabPane.getSelectedComponent() != outputErr )
            tabPane.setSelectedComponent(outputErr);
    }
}
项目:incubator-netbeans    文件:LeafView.java   
/** Gives notification from the document that attributes were removed
* in a location that this view is responsible for.
*
* @param e the change information from the associated document
* @param a the current allocation of the view
* @param f the factory to use to rebuild if the view has children
*/
public @Override void removeUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
    try {
        BaseDocumentEvent bevt = (BaseDocumentEvent)evt;
        EditorUI editorUI = getEditorUI();
        int y = getYFromPos(evt.getOffset());
        int lineHeight = editorUI.getLineHeight();
        if (bevt.getLFCount() > 0) { // one or more lines removed
            int removeHeight = bevt.getLFCount() * lineHeight;
            mainHeight -= removeHeight;
            editorUI.repaint(y);

        } else { // removing on one line
            int syntaxY = getYFromPos(bevt.getSyntaxUpdateOffset());
            // !!! patch for case when DocMarksOp.eolMark is at the end of document
            if (bevt.getSyntaxUpdateOffset() == evt.getDocument().getLength()) {
                syntaxY += lineHeight;
            }

            if (getComponent().isShowing()) {
                editorUI.repaint(y, Math.max(lineHeight, syntaxY - y));
            }
        }

    } catch (BadLocationException ex) {
        Utilities.annotateLoggable(ex);
    }
}
项目:incubator-netbeans    文件:PanelProjectLocationVisual.java   
public void changedUpdate( DocumentEvent e ) {
    updateTexts( e );
    if (this.projectNameTextField.getDocument() == e.getDocument()) {
        firePropertyChange (PROP_PROJECT_NAME,null,this.projectNameTextField.getText());
    }
    if (this.projectLocationTextField.getDocument() == e.getDocument()) {
        firePropertyChange (PROP_PROJECT_LOCATION,null,this.projectLocationTextField.getText());
    }
}
项目:rapidminer    文件:AutoCompletionComboBox.java   
@Override
public void insertUpdate(DocumentEvent e) {
    try {
        Vector<String> vectorOfStrings = new Vector<String>();
        for (int i = 0; i < getModel().getSize(); i++) {
            vectorOfStrings.add(String.valueOf(getModel().getElementAt(i)));
        }
        Document document = e.getDocument();
        String documentText = document.getText(0, document.getLength());
        final String result = checkForMatch(documentText, vectorOfStrings, caseSensitive);
        final String newString = (result == null) ? documentText : result;
        final int startSelect = document.getLength();
        final int endSelect = newString.length();
        final JTextField editorComponent = (JTextField) getEditor().getEditorComponent();

        if (startSelect == e.getOffset() + e.getLength()) {
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    setSelectedItem(newString);
                    editorComponent.getDocument().removeDocumentListener(docListener);
                    editorComponent.setText(newString);
                    editorComponent.getDocument().addDocumentListener(docListener);
                    Caret caret = editorComponent.getCaret();
                    caret.setDot(endSelect);
                    caret.moveDot(startSelect);
                }
            });
        }
    } catch (BadLocationException e1) {
    }
}
项目:BEAST    文件:TextChangedActionAdder.java   
@Override
public void insertUpdate(DocumentEvent de) {       
    if(!listen) return; 
    try {
        String added = pane.getStyledDocument().getText(de.getOffset(), de.getLength());

        TextAddedAction action = new TextAddedAction(
                new TextDelta(de.getOffset(), added),
                pane.getStyledDocument());
        actionList.add(action);
    } catch (BadLocationException ex) {
        Logger.getLogger(TextChangedActionAdder.class.getName()).log(Level.SEVERE, null, ex);
    }
}
项目:batmapper    文件:MapperPanel.java   
@Override
public void removeUpdate( DocumentEvent arg0 ) {
    if (this.room != null) {
        this.room.setNotes( this.roomNotes.getText() );
    }

}
项目:difftool    文件:DocumentManager.java   
private void processInsert(DocumentEvent e) throws BadLocationException {

            final Document document = e.getDocument();
            Element root = document.getDefaultRootElement();
            int start = root.getElementIndex(e.getOffset());
            int end = root.getElementIndex(e.getOffset() + e.getLength() - 1);
            Element startElement = root.getElement(start);
            Element endElement = root.getElement(end);
            if (start == end) {
                String newValue = getText(document, startElement);
                replaceLine(document, start, newValue);
                if (e.getOffset() + e.getLength() == startElement.getEndOffset()) {
                    Element startNext = root.getElement(start + 1);

                    insertLines(document, start + 1, Collections.singletonList(
                            getText(document, startNext)
                    ));
                }
            } else {
                removeLines(document, start, start);

                List<String> lines = new ArrayList<>();

                for (int line = start; line <= end; ++line) {
                    lines.add(getText(document, root.getElement(line)));
                }

               if (e.getOffset() + e.getLength() == endElement.getEndOffset() && end + 1 < root.getElementCount()) {
                    Element endNext = root.getElement(end + 1);
                    lines.add(getText(document, endNext));
                }

                insertLines(document, start, lines);
            }
        }
项目:openjdk-jdk10    文件:TableView.java   
protected void forwardUpdate(DocumentEvent.ElementChange ec,
                                 DocumentEvent e, Shape a, ViewFactory f) {
    super.forwardUpdate(ec, e, a, f);
    // A change in any of the table cells usually effects the whole table,
    // so redraw it all!
    if (a != null) {
        Component c = getContainer();
        if (c != null) {
            Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a :
                               a.getBounds();
            c.repaint(alloc.x, alloc.y, alloc.width, alloc.height);
        }
    }
}
项目:incubator-netbeans    文件:LeafView.java   
/** Gives notification that something was inserted into the document
* in a location that this view is responsible for.
*
* @param e the change information from the associated document
* @param a the current allocation of the view
* @param f the factory to use to rebuild if the view has children
*/
public @Override void insertUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
    try {
        BaseDocumentEvent bevt = (BaseDocumentEvent)evt;
        EditorUI editorUI = getEditorUI();
        int y = getYFromPos(evt.getOffset());
        int lineHeight = editorUI.getLineHeight();
        if (bevt.getLFCount() > 0) { // one or more lines inserted
            int addHeight = bevt.getLFCount() * lineHeight;
            mainHeight += addHeight;
            editorUI.repaint(y);

        } else { // inserting on one line

            int syntaxY = getYFromPos(bevt.getSyntaxUpdateOffset());
            // !!! patch for case when DocMarksOp.eolMark is at the end of document
            if (bevt.getSyntaxUpdateOffset() == evt.getDocument().getLength()) {
                syntaxY += lineHeight;
            }

            if (getComponent().isShowing()) {
                editorUI.repaint(y, Math.max(lineHeight, syntaxY - y));
            }
        }

    } catch (BadLocationException ex) {
        Utilities.annotateLoggable(ex);
    }
}
项目:incubator-netbeans    文件:GapDocumentView.java   
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f) {
    layoutLockDepth++;
    try {
        // Do not check pendingUpdate since changedUpdate() is likely invoked by BaseDocument.repaintBlock()
        super.changedUpdate(e, a, f);
    } finally {
        updateLayout();
        layoutLockDepth--;
    }
}
项目:jdk8u-jdk    文件:XTextAreaPeer.java   
@Override
public void removeUpdate(DocumentEvent e) {
    if (peer != null) {
        peer.postEvent(new TextEvent(peer.target,
                                     TextEvent.TEXT_VALUE_CHANGED));
    }
}
项目:incubator-netbeans    文件:QuickSearchPanel.java   
QuickSearchPanel(WizardDescriptor settings, DataModel data) {
    super(settings);
    this.data = data;
    initComponents();

    putClientProperty("NewFileWizard_Title", getMessage("LBL_QuickSearchPanel_Title"));

    DocumentListener dListener = new UIUtil.DocumentAdapter() {

        public void insertUpdate(DocumentEvent e) {
            checkValidity();
        }
    };

    if (data.getPackageName() != null) {
        packageCombo.setSelectedItem(data.getPackageName());
    }

    classNameTextField.getDocument().addDocumentListener(dListener);
    categoryNameTextField.getDocument().addDocumentListener(dListener);
    commandPrefixTextField.getDocument().addDocumentListener(dListener);
    positionTextField.getDocument().addDocumentListener(dListener);
    Component editorComp = packageCombo.getEditor().getEditorComponent();
    if (editorComp instanceof JTextComponent) {
        ((JTextComponent) editorComp).getDocument().addDocumentListener(dListener);
    }
}
项目:incubator-netbeans    文件:BasicPanelVisual.java   
@Override
public void changedUpdate(DocumentEvent e) {
    updateTexts(e);
    if (this.projectNameTextField.getDocument() == e.getDocument()) {
        firePropertyChange(PROP_PROJECT_NAME,null,this.projectNameTextField.getText());
    }
}
项目:jdk8u-jdk    文件:XTextFieldPeer.java   
@Override
public void changedUpdate(DocumentEvent e) {
    if (peer != null) {
        peer.postEvent(new TextEvent(peer.target,
                                     TextEvent.TEXT_VALUE_CHANGED));
    }
}
项目:OpenJSharp    文件:XTextFieldPeer.java   
@Override
public void insertUpdate(DocumentEvent e) {
    if (peer != null) {
        peer.postEvent(new TextEvent(peer.target,
                                     TextEvent.TEXT_VALUE_CHANGED));
    }
}
项目:incubator-netbeans    文件:PanelProjectLocationVisual.java   
public void removeUpdate( DocumentEvent e ) {
    updateTexts( e );
    if (this.projectNameTextField.getDocument() == e.getDocument()) {
        firePropertyChange (PROP_PROJECT_NAME,null,this.projectNameTextField.getText());
    }
    if (this.projectLocationTextField.getDocument() == e.getDocument()) {
        firePropertyChange (PROP_PROJECT_LOCATION,null,this.projectLocationTextField.getText());
    }
}
项目:incubator-netbeans    文件:WeakPositions.java   
@Override
public void removeUpdate(DocumentEvent e) {
    synchronized (OGLS) {
        OffsetGapList<WeakPositions.WeakP> ogl = getOgl(e);
        if (ogl != null) {
            ogl.defaultRemoveUpdate(e.getOffset(), e.getLength());
        }
    }
}
项目:incubator-netbeans    文件:DocumentUtilities.java   
/**
 * Set a property of a given document event.
 *
 * @param evt non-null document event to which the property should be stored.
 * @param key non-null key of the property.
 * @param value for the given property.
 */
public static void putEventProperty(DocumentEvent evt, Object key, Object value) {
    EventPropertiesElementChange change = (EventPropertiesElementChange)
            evt.getChange(EventPropertiesElement.INSTANCE);
    if (change == null) {
        throw new IllegalStateException("addEventPropertyStorage() not called for evt=" + evt); // NOI18N
    }
    change.putProperty(key, value);
}
项目:incubator-netbeans    文件:ProjectCopyPanel.java   
public void insertUpdate(DocumentEvent e) {
    if (e.getDocument().equals(projectLocation.getDocument())) {
        if (lastComputedName != null && lastComputedName.equals(projectName.getText())) {
            projectName.setText(computeValidProjectName(new File(projectLocation.getText()).getAbsolutePath(), 
                    ProjectUtils.getInformation(project).getName()));
        }            
    }
    updateProjectFolder();
    validateDialog();
}
项目:incubator-netbeans    文件:LockView.java   
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f) {
    lock();
    try {

        if (view != null) {
            view.changedUpdate(e, a, f);
        }

    } finally {
        unlock();
    }
}
项目:incubator-netbeans    文件:BasicPanelVisual.java   
@Override
public void removeUpdate(DocumentEvent e) {
    updateTexts(e);
    if (this.projectNameTextField.getDocument() == e.getDocument()) {
        firePropertyChange(PROP_PROJECT_NAME,null,this.projectNameTextField.getText());
    }
}
项目:Lang871    文件:CodeListener.java   
@Override
public void removeUpdate(DocumentEvent e)
{

}
项目:incubator-netbeans    文件:CoverageHighlightsContainer.java   
public void changedUpdate(DocumentEvent ev) {
}
项目:incubator-netbeans    文件:StatusBar.java   
public void removeUpdate(DocumentEvent evt) {
    if (evt.getType() == DocumentEvent.EventType.INSERT) { // undo
        documentUndo(evt);
    }
}
项目:Pogamut3    文件:TemplateBotProjectPanelVisual.java   
public void changedUpdate(DocumentEvent e) {
    updateTexts(e);
    if (this.projectNameTextField.getDocument() == e.getDocument()) {
        firePropertyChange(PROP_PROJECT_NAME,null,this.projectNameTextField.getText());
    }
}
项目:incubator-netbeans    文件:BaseDocumentTest.java   
public void insertUpdate(DocumentEvent e) {
    // less, not less and equal
    if (e.getOffset() < offset) {
        offset += e.getLength();
    }
}
项目:bitbox    文件:BaseConverter.java   
@Override
public void insertUpdate(DocumentEvent documentEvent) {
    updateSingleField((EditableBaseLogicGUI) documentEvent.getDocument().getProperty("parentEditable"));
}
项目:incubator-netbeans    文件:DocumentModel.java   
public void changedUpdate(javax.swing.event.DocumentEvent documentEvent) {
    //no need to handle document attributes changes
}
项目:OpenJSharp    文件:CAccessible.java   
@Override
public void changedUpdate(DocumentEvent e) {
    if (ptr != 0) valueChanged(ptr);
}
项目:incubator-netbeans    文件:AttachmentPanel.java   
@Override
public void removeUpdate (DocumentEvent e) {
    fieldUpdated(e.getDocument());
}
项目:incubator-netbeans    文件:ComboBoxAutoCompleteSupport.java   
@Override
public void changedUpdate( DocumentEvent e ) {
    matchSelection( e );
}
项目:incubator-netbeans    文件:PanelProjectLocationVisual.java   
@Override
public void removeUpdate(DocumentEvent e) {
    updateTexts(e);
}
项目:incubator-netbeans    文件:Merge.java   
@Override
public void removeUpdate(DocumentEvent e) {
    setPreviewLabels();
}
项目:incubator-netbeans    文件:GoToPanelImpl.java   
public void changedUpdate( DocumentEvent e ) {
    update();
}