类javax.swing.event.UndoableEditListener源码实例Demo

下面列出了怎么用javax.swing.event.UndoableEditListener的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: PIPE   文件: PipeApplicationController.java
/**
 * Register the tab to the Petri net
 * @param net Petri net
 * @param tab tab which houses the graphical petri net components
 * @param historyObserver listener for stepback/forward events in animation
 * @param undoListener listener for undo/redo events
 * @param zoomListener listener for zoom events
 */
//TODO: THIS IS RATHER UGLY, too many params but better than what was here before
public void registerTab(PetriNet net, PetriNetTab tab, Observer historyObserver, UndoableEditListener undoListener,
                        PropertyChangeListener zoomListener) {
    AnimationHistoryImpl animationHistory = new AnimationHistoryImpl();
    animationHistory.addObserver(historyObserver);
    GUIAnimator animator = new GUIAnimator(new PetriNetAnimator(net), animationHistory, this);

    CopyPasteManager copyPasteManager = new CopyPasteManager(undoListener, tab, net, this);

    ZoomController zoomController = new ZoomController(100);
    tab.addZoomListener(zoomController);
    PetriNetController petriNetController =
            new PetriNetController(net, undoListener, animator, copyPasteManager, zoomController, tab);
    netControllers.put(tab, petriNetController);
    tab.updatePreferredSize();

    PropertyChangeListener changeListener =
            new PetriNetChangeListener(applicationModel, tab, petriNetController);
    net.addPropertyChangeListener(changeListener);

    setActiveTab(tab);
    initialiseNet(net, changeListener);
}
 
源代码2 项目: jeveassets   文件: TextManager.java
public static void installTextComponent(final JTextComponent component) {
	//Make sure this component does not already have a UndoManager
	Document document = component.getDocument();
	boolean found = false;
	if (document instanceof AbstractDocument) {
		AbstractDocument abstractDocument = (AbstractDocument) document;
		for (UndoableEditListener editListener : abstractDocument.getUndoableEditListeners()) {
			if (editListener.getClass().equals(CompoundUndoManager.class)) {
				CompoundUndoManager undoManager = (CompoundUndoManager) editListener;
				undoManager.reset();
				return;
			}
		}
	}
	if (!found) {
		new TextManager(component);
	}
}
 
源代码3 项目: PIPE   文件: ComponentEditorManager.java
/**
 * Creates actions for editing the petri net
 *
 * @param controller PIPE application controller
 */
public ComponentEditorManager(PipeApplicationController controller) {
    copyAction = new CopyAction(controller);
    pasteAction = new PasteAction(controller);
    cutAction = new CutAction(controller);
    deleteAction = new DeleteAction(controller);
    undoAction = new UndoAction(controller);
    redoAction = new RedoAction(controller, undoAction);
    undoAction.registerRedoAction(redoAction);
    undoAction.setEnabled(false);
    redoAction.setEnabled(false);

    UndoableEditListener listener = new SimpleUndoListener(redoAction, undoAction, controller);
    deleteAction.addUndoableEditListener(listener);
    copyAction.addUndoableEditListener(listener);
    cutAction.addUndoableEditListener(listener);
    pasteAction.addUndoableEditListener(listener);

    storeEnabledStatus();
}
 
源代码4 项目: PIPE   文件: TokenActionManager.java
/**
 * Constructor
 * @param undoListener undo listener
 * @param applicationModel PIPE application model
 * @param applicationController PIPE application controller
 * @param applicationView PIPE application view
 */
public TokenActionManager(UndoableEditListener undoListener, PipeApplicationModel applicationModel,
                          PipeApplicationController applicationController, PipeApplicationView applicationView) {
    tokenAction = new AddTokenAction(applicationModel);
    deleteTokenAction = new DeleteTokenAction(applicationModel);
    specifyTokenClasses = new SpecifyTokenAction(applicationController, applicationView);
    tokenAction.addUndoableEditListener(undoListener);
    deleteTokenAction.addUndoableEditListener(undoListener);
    specifyTokenClasses.addUndoableEditListener(undoListener);
}
 
void sendUndoableEdit(Document d, UndoableEdit ue) {
    if(d instanceof AbstractDocument) {
        UndoableEditListener[] uels = ((AbstractDocument)d).getUndoableEditListeners();
        UndoableEditEvent ev = new UndoableEditEvent(d, ue);
        for(UndoableEditListener uel : uels) {
            uel.undoableEditHappened(ev);
        }
    }
}
 
源代码6 项目: netbeans   文件: BaseDocument.java
@Override
public void addUndoableEditListener(UndoableEditListener listener) {
    super.addUndoableEditListener(listener);
    if (LOG.isLoggable(Level.FINE)) {
        UndoableEditListener[] listeners = getUndoableEditListeners();
        if (listeners.length > 1) {
            // Having two UE listeners may be dangerous - for example
            // having two undo managers attached at once will lead to strange errors
            // since only one of the UMs will work normally while processing
            // in the other one will be (typically silently) failing.
            LOG.log(Level.INFO, "Two or more UndoableEditListeners attached", new Exception()); // NOI18N
        }
    }
}
 
源代码7 项目: netbeans   文件: BaseDocumentTest.java
public void testRecursiveUndoableEdits() throws Exception {
    final BaseDocument doc = new BaseDocument(false, "text/plain");
    class UEL implements UndoableEditListener, Runnable {
        boolean undo;
        @Override
        public void undoableEditHappened(UndoableEditEvent e) {
            //doc.runAtomic(this);
            doc.render(this);
            undo = e.getEdit().canUndo();
        }

        @Override
        public void run() {
        }
    }
    UEL uel = new UEL();
    doc.addUndoableEditListener(uel);

    class Atom implements Runnable {
        @Override
        public void run() {
            try {
                doc.insertString(0, "Ahoj", null);
            } catch (BadLocationException ex) {
                throw new IllegalStateException(ex);
            }
        }
    }
    doc.runAtomicAsUser(new Atom());

    assertTrue("Can undo now", uel.undo);
}
 
源代码8 项目: netbeans   文件: CompletionImpl.java
static void sendUndoableEdit(Document d, UndoableEdit ue) {
    if(d instanceof AbstractDocument) {
        UndoableEditListener[] uels = ((AbstractDocument)d).getUndoableEditListeners();
        UndoableEditEvent ev = new UndoableEditEvent(d, ue);
        for(UndoableEditListener uel : uels) {
            uel.undoableEditHappened(ev);
        }
    }
}
 
源代码9 项目: netbeans   文件: AbstractModel.java
@Override
public synchronized void addUndoableRefactorListener(UndoableEditListener uel) {
    //
    savedUndoableEditListeners = ues.getUndoableEditListeners();
    if (savedUndoableEditListeners != null) {
        for (UndoableEditListener saved : savedUndoableEditListeners) {
            if (saved instanceof UndoManager) {
                ((UndoManager)saved).discardAllEdits();
            }
        }
    }
    ues = new ModelUndoableEditSupport();
    ues.addUndoableEditListener(uel);
}
 
源代码10 项目: netbeans   文件: MacroDialogSupport.java
private static void sendUndoableEdit(Document d, UndoableEdit ue) {
    if(d instanceof AbstractDocument) {
        UndoableEditListener[] uels = ((AbstractDocument)d).getUndoableEditListeners();
        UndoableEditEvent ev = new UndoableEditEvent(d, ue);
        for(UndoableEditListener uel : uels) {
            uel.undoableEditHappened(ev);
        }
    }
}
 
源代码11 项目: netbeans   文件: AbbrevDetection.java
private static void sendUndoableEdit(Document d, UndoableEdit ue) {
    if(d instanceof AbstractDocument) {
        UndoableEditListener[] uels = ((AbstractDocument)d).getUndoableEditListeners();
        UndoableEditEvent ev = new UndoableEditEvent(d, ue);
        for(UndoableEditListener uel : uels) {
            uel.undoableEditHappened(ev);
        }
    }
}
 
源代码12 项目: PIPE   文件: ComponentCreatorManager.java
public ComponentCreatorManager(UndoableEditListener undoListener, PipeApplicationModel applicationModel,
                               PipeApplicationController applicationController) {
    placeAction = new PlaceAction(applicationModel);

    transAction = new ImmediateTransitionAction(applicationModel);

    timedtransAction = new TimedTransitionAction(applicationModel);

    annotationAction = new AnnotationAction(applicationModel);

    inhibarcAction =
            new ArcAction("Inhibitor Arc", "Add an inhibitor arc (alt-h)", KeyEvent.VK_H, InputEvent.ALT_DOWN_MASK,
                    new InhibitorSourceVisitor(), new InhibitorCreator(), applicationModel,
                    applicationController, new InhibitorArcHead());
    arcAction = new ArcAction("Arc", "Add an arc (alt-a)", KeyEvent.VK_A, InputEvent.ALT_DOWN_MASK,
            new NormalArcSourceVisitor(), new NormalCreator(applicationController), applicationModel,
            applicationController,
            new NormalHead());

    rateParameterAction = new SpecifyRateParameterAction(applicationController);

    placeAction.addUndoableEditListener(undoListener);
    transAction.addUndoableEditListener(undoListener);
    timedtransAction.addUndoableEditListener(undoListener);
    arcAction.addUndoableEditListener(undoListener);
    inhibarcAction.addUndoableEditListener(undoListener);
    annotationAction.addUndoableEditListener(undoListener);
    rateParameterAction.addUndoableEditListener(undoListener);
}
 
源代码13 项目: visualvm   文件: SyntaxDocument.java
public SyntaxDocument(Lexer lexer) {
    super();
    putProperty(PlainDocument.tabSizeAttribute, 4);
    this.lexer = lexer;
    // Listen for undo and redo events
    addUndoableEditListener(new UndoableEditListener() {

        @Override
        public void undoableEditHappened(UndoableEditEvent evt) {
            if (evt.getEdit().isSignificant()) {
                undo.addEdit(evt.getEdit());
            }
        }
    });
}
 
源代码14 项目: PIPE   文件: CopyPasteManager.java
/**
 * Constructor
 *
 * @param listener              undoable event listener, used to register undo events to
 * @param petriNetTab           current Petri net tab
 * @param net                   underlying Petri net displayed on the Petri net tab
 * @param applicationController main application controller
 */
public CopyPasteManager(UndoableEditListener listener, PetriNetTab petriNetTab, PetriNet net,
                        PipeApplicationController applicationController) {
    this.petriNetTab = petriNetTab;
    petriNet = net;
    this.applicationController = applicationController;
    addMouseListener(this);
    addMouseMotionListener(this);
    addKeyListener(this);
    this.listener = listener;

}
 
源代码15 项目: dragonwell8_jdk   文件: Test6968363.java
@Override
public void addUndoableEditListener(UndoableEditListener listener) {
    this.document.addUndoableEditListener(listener);
}
 
源代码16 项目: dragonwell8_jdk   文件: Test6968363.java
@Override
public void removeUndoableEditListener(UndoableEditListener listener) {
    this.document.removeUndoableEditListener(listener);
}
 
源代码17 项目: TencentKona-8   文件: Test6968363.java
@Override
public void addUndoableEditListener(UndoableEditListener listener) {
    this.document.addUndoableEditListener(listener);
}
 
源代码18 项目: TencentKona-8   文件: Test6968363.java
@Override
public void removeUndoableEditListener(UndoableEditListener listener) {
    this.document.removeUndoableEditListener(listener);
}
 
源代码19 项目: jdk8u60   文件: Test6968363.java
@Override
public void addUndoableEditListener(UndoableEditListener listener) {
    this.document.addUndoableEditListener(listener);
}
 
源代码20 项目: consulo   文件: EditorComponentImpl.java
@Override
public void removeUndoableEditListener(UndoableEditListener undoableEditListener) {
}
 
源代码21 项目: openjdk-jdk8u   文件: Test6968363.java
@Override
public void addUndoableEditListener(UndoableEditListener listener) {
    this.document.addUndoableEditListener(listener);
}
 
源代码22 项目: openjdk-jdk8u   文件: Test6968363.java
@Override
public void removeUndoableEditListener(UndoableEditListener listener) {
    this.document.removeUndoableEditListener(listener);
}
 
源代码23 项目: netbeans   文件: InstantRefactoringPerformer.java
public InstantRefactoringPerformer(final JTextComponent target, int caretOffset, InstantRefactoringUI ui) {
    releaseAll();
    this.target = target;
    this.ui = ui;
    doc = target.getDocument();

    MutablePositionRegion mainRegion = null;
    List<MutablePositionRegion> regions = new ArrayList<>(ui.getRegions().size());

    for (MutablePositionRegion current : ui.getRegions()) {
        // TODO: type parameter name is represented as ident -> ignore surrounding <> in rename
        if (isIn(current, caretOffset)) {
            mainRegion = current;
        } else {
            regions.add(current);
        }
    }

    if (mainRegion == null) {
        throw new IllegalArgumentException("No highlight contains the caret.");
    }

    regions.add(0, mainRegion);

    region = new SyncDocumentRegion(doc, regions);

    if (doc instanceof BaseDocument) {
        BaseDocument bdoc = ((BaseDocument) doc);
        bdoc.addPostModificationDocumentListener(this);
        
        UndoableWrapper wrapper = MimeLookup.getLookup("text/x-java").lookup(UndoableWrapper.class);
        if(wrapper != null) {
            wrapper.setActive(true, this);
        }

        UndoableEdit undo = new CancelInstantRenameUndoableEdit(this);
        for (UndoableEditListener l : bdoc.getUndoableEditListeners()) {
            l.undoableEditHappened(new UndoableEditEvent(doc, undo));
        }
    }

    target.addKeyListener(this);

    target.putClientProperty(InstantRefactoringPerformer.class, this);
    target.putClientProperty("NetBeansEditor.navigateBoundaries", mainRegion); // NOI18N
	
    requestRepaint();
    
    target.select(mainRegion.getStartOffset(), mainRegion.getEndOffset());
    
    span = region.getFirstRegionLength();
    compl = new CompletionLayout(this);
    compl.setEditorComponent(target);
    final KeyStroke OKKS = ui.getKeyStroke();
    target.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(OKKS, OKActionKey);
    Action OKAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if(registry.contains(InstantRefactoringPerformer.this)) {
                doFullRefactoring();
                target.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).remove(OKKS);
                target.getActionMap().remove(OKActionKey);
            } else {
                target.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).remove(OKKS);
                target.getActionMap().remove(OKActionKey);
            }
        }
    };
    target.getActionMap().put(OKActionKey, OKAction);
    final KeyStroke keyStroke = ui.getKeyStroke();
    compl.showCompletion(ui.getOptions(), caretOffset, Bundle.INFO_PressAgain(getKeyStrokeAsText(keyStroke)));
    
    registry.add(this);
}
 
源代码24 项目: netbeans   文件: InstantRenamePerformer.java
/** Creates a new instance of InstantRenamePerformer */
private InstantRenamePerformer(JTextComponent target, Set<Token> highlights, int caretOffset) throws BadLocationException {
    this.target = target;
    doc = target.getDocument();

    MutablePositionRegion mainRegion = null;
    List<MutablePositionRegion> regions = new ArrayList<MutablePositionRegion>();

    for (Token h : highlights) {
        // type parameter name is represented as ident -> ignore surrounding <> in rename
        int delta = h.id() == JavadocTokenId.IDENT && h.text().charAt(0) == '<' && h.text().charAt(h.length() - 1) == '>' ? 1 : 0;
        Position start = NbDocument.createPosition(doc, h.offset(null) + delta, Bias.Backward);
        Position end = NbDocument.createPosition(doc, h.offset(null) + h.length() - delta, Bias.Forward);
        MutablePositionRegion current = new MutablePositionRegion(start, end);
        
        if (isIn(current, caretOffset)) {
            mainRegion = current;
        } else {
            regions.add(current);
        }
    }

    if (mainRegion == null) {
        throw new IllegalArgumentException("No highlight contains the caret.");
    }

    regions.add(0, mainRegion);

    region = new SyncDocumentRegion(doc, regions);

    if (doc instanceof BaseDocument) {
        BaseDocument bdoc = ((BaseDocument) doc);
        bdoc.setPostModificationDocumentListener(this);

        UndoableEdit undo = new CancelInstantRenameUndoableEdit(this);
        for (UndoableEditListener l : bdoc.getUndoableEditListeners()) {
            l.undoableEditHappened(new UndoableEditEvent(doc, undo));
        }
    }

    target.addKeyListener(this);

    target.putClientProperty(InstantRenamePerformer.class, this);
    target.putClientProperty("NetBeansEditor.navigateBoundaries", mainRegion); // NOI18N
	
    requestRepaint();
    
    target.select(mainRegion.getStartOffset(), mainRegion.getEndOffset());
    
    span = region.getFirstRegionLength();
    
    registry.add(this);
    sendUndoableEdit(doc, CloneableEditorSupport.BEGIN_COMMIT_GROUP);
}
 
源代码25 项目: PIPE   文件: PipeApplicationView.java
public void setUndoListener(UndoableEditListener listener) {
    undoListener = listener;
}
 
源代码26 项目: PIPE   文件: GuiAction.java
/**
 * Adds a listener to this action that is interested in undoable actions
 * @param l listener
 */
public void addUndoableEditListener(UndoableEditListener l) {
    //TODO: Should ideally throw an exception if listener != null
    listener = l;
}
 
源代码27 项目: netbeans   文件: OutputDocument.java
public void addUndoableEditListener(UndoableEditListener listener) {
    //no-op
}
 
源代码28 项目: netbeans   文件: OutputDocument.java
public void removeUndoableEditListener(UndoableEditListener listener) {
    //no-op
}
 
protected DummyController(Place component, UndoableEditListener listener) {
    super(component, listener);
}
 
源代码30 项目: netbeans   文件: AbstractModel.java
@Override
public void removeUndoableEditListener(UndoableEditListener uel) {
    ues.removeUndoableEditListener(uel);
}
 
 类所在包
 同包方法