/** * 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); } }
/** 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()); } }
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; }
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; } } } }
/** * 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)); } } }; }
/** 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); // } }
/** * ȭ���� ������ �ٲ� 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); } }
/** 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); } }
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()); } }
@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) { } }
@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); } }
@Override public void removeUpdate( DocumentEvent arg0 ) { if (this.room != null) { this.room.setNotes( this.roomNotes.getText() ); } }
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); } }
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); } } }
/** 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); } }
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--; } }
@Override public void removeUpdate(DocumentEvent e) { if (peer != null) { peer.postEvent(new TextEvent(peer.target, TextEvent.TEXT_VALUE_CHANGED)); } }
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); } }
@Override public void changedUpdate(DocumentEvent e) { updateTexts(e); if (this.projectNameTextField.getDocument() == e.getDocument()) { firePropertyChange(PROP_PROJECT_NAME,null,this.projectNameTextField.getText()); } }
@Override public void changedUpdate(DocumentEvent e) { if (peer != null) { peer.postEvent(new TextEvent(peer.target, TextEvent.TEXT_VALUE_CHANGED)); } }
@Override public void insertUpdate(DocumentEvent e) { if (peer != null) { peer.postEvent(new TextEvent(peer.target, TextEvent.TEXT_VALUE_CHANGED)); } }
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()); } }
@Override public void removeUpdate(DocumentEvent e) { synchronized (OGLS) { OffsetGapList<WeakPositions.WeakP> ogl = getOgl(e); if (ogl != null) { ogl.defaultRemoveUpdate(e.getOffset(), e.getLength()); } } }
/** * 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); }
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(); }
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f) { lock(); try { if (view != null) { view.changedUpdate(e, a, f); } } finally { unlock(); } }
@Override public void removeUpdate(DocumentEvent e) { updateTexts(e); if (this.projectNameTextField.getDocument() == e.getDocument()) { firePropertyChange(PROP_PROJECT_NAME,null,this.projectNameTextField.getText()); } }
@Override public void removeUpdate(DocumentEvent e) { }
public void changedUpdate(DocumentEvent ev) { }
public void removeUpdate(DocumentEvent evt) { if (evt.getType() == DocumentEvent.EventType.INSERT) { // undo documentUndo(evt); } }
public void changedUpdate(DocumentEvent e) { updateTexts(e); if (this.projectNameTextField.getDocument() == e.getDocument()) { firePropertyChange(PROP_PROJECT_NAME,null,this.projectNameTextField.getText()); } }
public void insertUpdate(DocumentEvent e) { // less, not less and equal if (e.getOffset() < offset) { offset += e.getLength(); } }
@Override public void insertUpdate(DocumentEvent documentEvent) { updateSingleField((EditableBaseLogicGUI) documentEvent.getDocument().getProperty("parentEditable")); }
public void changedUpdate(javax.swing.event.DocumentEvent documentEvent) { //no need to handle document attributes changes }
@Override public void changedUpdate(DocumentEvent e) { if (ptr != 0) valueChanged(ptr); }
@Override public void removeUpdate (DocumentEvent e) { fieldUpdated(e.getDocument()); }
@Override public void changedUpdate( DocumentEvent e ) { matchSelection( e ); }
@Override public void removeUpdate(DocumentEvent e) { updateTexts(e); }
@Override public void removeUpdate(DocumentEvent e) { setPreviewLabels(); }
public void changedUpdate( DocumentEvent e ) { update(); }