Search in sources :

Example 1 with UndoableEditEvent

use of javax.swing.event.UndoableEditEvent in project jadx by skylot.

the class TextStandardActions method registerListeners.

private void registerListeners() {
    textComponent.addMouseListener(new MouseAdapter() {

        public void mouseReleased(MouseEvent e) {
            if (e.getModifiers() == InputEvent.BUTTON3_MASK && e.getSource() == textComponent) {
                process(e);
            }
        }
    });
    textComponent.getDocument().addUndoableEditListener(new UndoableEditListener() {

        public void undoableEditHappened(UndoableEditEvent event) {
            undoManager.addEdit(event.getEdit());
        }
    });
}
Also used : UndoableEditListener(javax.swing.event.UndoableEditListener) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) UndoableEditEvent(javax.swing.event.UndoableEditEvent)

Example 2 with UndoableEditEvent

use of javax.swing.event.UndoableEditEvent in project enclojure by EricThorsen.

the class ReplPanel method createReplEditorPane.

public void createReplEditorPane() {
    try {
        Var createReplEditorPaneFn = RT.var("org.enclojure.ide.repl.repl-panel", "create-repl-editor-pane");
        _replEditorPane = (JEditorPane) createReplEditorPaneFn.invoke(this);
    } catch (Exception ex) {
        Logger.getLogger(ReplPanel.class.getName()).log(Level.SEVERE, null, ex);
    }
    // ??_replEditorPane.setInheritsPopupMenu(true);
    jScrollPaneRepl.setViewportView(_replEditorPane);
    _replEditorPane.getDocument().addUndoableEditListener(new UndoableEditListener() {

        public void undoableEditHappened(UndoableEditEvent e) {
            _undoManager.addEdit(e.getEdit());
        }
    });
    _replEditorPane.addKeyListener(new java.awt.event.KeyAdapter() {

        public void keyTyped(java.awt.event.KeyEvent evt) {
            processCharInput(evt);
        }

        public void keyPressed(java.awt.event.KeyEvent evt) {
            processKeyInput(evt);
        }
    });
}
Also used : UndoableEditListener(javax.swing.event.UndoableEditListener) Var(clojure.lang.Var) UndoableEditEvent(javax.swing.event.UndoableEditEvent) KeyEvent(java.awt.event.KeyEvent) BadLocationException(javax.swing.text.BadLocationException)

Example 3 with UndoableEditEvent

use of javax.swing.event.UndoableEditEvent in project vcell by virtualcell.

the class VirtualFrapMainFrame method initiateComponents.

/**
 * Initiation of the UI components that is shown in the main window
 */
protected void initiateComponents(DocumentWindowManager documentWindowManager) {
    toolBar = new ToolBar();
    toolBar.setNewAndRunButtonVisible(false);
    ToolBarHandler th = new ToolBarHandler();
    toolBar.addToolBarHandler(th);
    mb = new JMenuBar();
    frapStudyPanel = new FRAPStudyPanel();
    frapStudyPanel.addUndoableEditListener(new UndoableEditListener() {

        public void undoableEditHappened(UndoableEditEvent e) {
            if (e.getEdit().canUndo()) {
                lastUndoableEdit = e.getEdit();
                mUndo.setText(UNDO_ACTION_COMMAND + " " + e.getEdit().getUndoPresentationName());
                mUndo.setEnabled(true);
            } else {
                lastUndoableEdit = null;
                mUndo.setText(UNDO_ACTION_COMMAND);
                mUndo.setEnabled(false);
            }
        }
    });
    // System.setProperty(PropertyLoader.primarySimDataDirProperty, localWorkspace.getDefaultWorkspaceDirectory());
    // System.setProperty(PropertyLoader.secondarySimDataDirProperty, localWorkspace.getDefaultWorkspaceDirectory());
    System.setProperty(PropertyLoader.exportBaseDirInternalProperty, localWorkspace.getDefaultSimDataDirectory());
    System.setProperty(PropertyLoader.exportBaseURLProperty, "file://" + localWorkspace.getDefaultSimDataDirectory());
    frapStudyPanel.setLocalWorkspace(localWorkspace);
    frapStudyPanel.setFRAPWorkspace(frapWorkspace);
    frapStudyPanel.setDocumentWindowManager(documentWindowManager);
    // add components to the main frame
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(toolBar, BorderLayout.NORTH);
    getContentPane().add(statusBarNew, BorderLayout.SOUTH);
    getContentPane().add(frapStudyPanel);
}
Also used : UndoableEditListener(javax.swing.event.UndoableEditListener) BorderLayout(java.awt.BorderLayout) UndoableEditEvent(javax.swing.event.UndoableEditEvent) JMenuBar(javax.swing.JMenuBar)

Example 4 with UndoableEditEvent

use of javax.swing.event.UndoableEditEvent in project vcell by virtualcell.

the class AddShapeJPanel method init.

private void init() {
    cylAxisButtonGroup.add(cylXRadioButton);
    cylAxisButtonGroup.add(cylYRadioButton);
    cylAxisButtonGroup.add(cylZRadioButton);
    cylXRadioButton.addActionListener(shapeTypeComboBoxActionListener);
    cylYRadioButton.addActionListener(shapeTypeComboBoxActionListener);
    cylZRadioButton.addActionListener(shapeTypeComboBoxActionListener);
    comboBox.addActionListener(shapeTypeComboBoxActionListener);
    copyExpressionTextButton.setEnabled(false);
    populateShapeTypeComboBox(1);
    UndoableEditListener undoableEditListener = new UndoableEditListener() {

        public void undoableEditHappened(UndoableEditEvent e) {
            setAnalyticExprLabel();
        }
    };
    circleCenterTextField.getDocument().addUndoableEditListener(undoableEditListener);
    circleRadiusTextField.getDocument().addUndoableEditListener(undoableEditListener);
    boxLCTextField.getDocument().addUndoableEditListener(undoableEditListener);
    boxUCTextField.getDocument().addUndoableEditListener(undoableEditListener);
    ellipseCenterTextField.getDocument().addUndoableEditListener(undoableEditListener);
    axisRadiiTextField.getDocument().addUndoableEditListener(undoableEditListener);
    cylStartPointTextField.getDocument().addUndoableEditListener(undoableEditListener);
    cylRadiusTextField.getDocument().addUndoableEditListener(undoableEditListener);
    cylLengthTextField.getDocument().addUndoableEditListener(undoableEditListener);
    manualTextField.getDocument().addUndoableEditListener(undoableEditListener);
    setAnalyticExprLabel();
}
Also used : UndoableEditListener(javax.swing.event.UndoableEditListener) UndoableEditEvent(javax.swing.event.UndoableEditEvent)

Example 5 with UndoableEditEvent

use of javax.swing.event.UndoableEditEvent in project pcgen by PCGen.

the class ExtendedHTMLDocument method removeElements.

/**
	 * Removes elements.  Used by Swing.
	 *
	 * @param e the element to remove
	 * @param index the element position
	 * @param count how many to remove
	 *
	 * @throws BadLocationException if there are not elements enough
	 *
	 * @see Content#remove(int, int)
	 */
public void removeElements(Element e, int index, int count) throws BadLocationException {
    writeLock();
    int start = e.getElement(index).getStartOffset();
    int end = e.getElement((index + count) - 1).getEndOffset();
    try {
        Element[] removed = new Element[count];
        Element[] added = EMPTY_ELEMENT_ARRAY;
        for (int counter = 0; counter < count; counter++) {
            removed[counter] = e.getElement(counter + index);
        }
        DefaultDocumentEvent dde = new DefaultDocumentEvent(start, end - start, EventType.REMOVE);
        ((AbstractDocument.BranchElement) e).replace(index, removed.length, added);
        dde.addEdit(new ElementEdit(e, index, removed, added));
        UndoableEdit u = getContent().remove(start, end - start);
        if (u != null) {
            dde.addEdit(u);
        }
        postRemoveUpdate(dde);
        dde.end();
        fireRemoveUpdate(dde);
        if (u != null) {
            fireUndoableEditUpdate(new UndoableEditEvent(this, dde));
        }
    } finally {
        writeUnlock();
    }
}
Also used : UndoableEdit(javax.swing.undo.UndoableEdit) UndoableEditEvent(javax.swing.event.UndoableEditEvent)

Aggregations

UndoableEditEvent (javax.swing.event.UndoableEditEvent)7 UndoableEditListener (javax.swing.event.UndoableEditListener)5 TextFieldAutoCompletion (cbit.gui.TextFieldAutoCompletion)1 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)1 ExpressionException (cbit.vcell.parser.ExpressionException)1 Var (clojure.lang.Var)1 BorderLayout (java.awt.BorderLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 KeyEvent (java.awt.event.KeyEvent)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 PropertyVetoException (java.beans.PropertyVetoException)1 JMenuBar (javax.swing.JMenuBar)1 BadLocationException (javax.swing.text.BadLocationException)1 UndoableEdit (javax.swing.undo.UndoableEdit)1