Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 package org.apache.cayenne.modeler.undo;
 
 
 
 import  org.apache.cayenne.map.DataMap;
 import  org.apache.cayenne.map.DbEntity;
 import  org.apache.cayenne.map.ObjEntity;
 
 public class JTextFieldUndoListener implements UndoableEditListener {
 
 
 	private Object currentObj;
 	private TreePath[] paths;
 
 	private int lastOffset;
 	private int lastLength;
 
 	private JTextFieldUndoListener self = this;
 
 	private boolean inProgress = false;
 
 	private class UndoDocumentListener implements DocumentListener {
 
 		public void changedUpdate(DocumentEvent e) {
 		}
 
 		public void insertUpdate(final DocumentEvent e) {
 			SwingUtilities.invokeLater(new Runnable() {
 
 				public void run() {
 					int offset = e.getOffset() + e.getLength();
 					offset = Math.min(offset.getDocument()
 							.getLength());
 				}
 			});
 		}
 
 		public void removeUpdate(DocumentEvent e) {
 		}
 
 	}
 
 	public JTextFieldUndoListener(JTextComponent textComponent) {
 		this. = textComponent;
 		this. = Application.getInstance().getUndoManager();
 
 
 			public void focusGained(FocusEvent e) {
 				if (. == null) {
 					. = ((CayenneModelerFrame) Application
				}
			}
			public void focusLost(FocusEvent e) {
				. = null;
				if ( != null) {
					 = null;
				}
			}
		});
			public void keyPressed(KeyEvent e) {
				 = true;
			}
			public void keyReleased(KeyEvent e) {
			}
			public void keyTyped(KeyEvent e) {
			}
		});
	}
		if () {
			if ( == null) {
else {
					return;
				}
				int offsetChange = .getCaretPosition()
				int lengthChange = .getDocument().getLength()
				if (offsetChange == lengthChange && Math.abs(offsetChange) == 1) {
					return;
else {
				}
			}
		}
	}
		CompoundEdit compoundEdit = new TextCompoundEdit();
		compoundEdit.addEdit(e);
		.addEdit(compoundEdit);
		return compoundEdit;
	}
	private class TextCompoundEdit extends CompoundEdit {
		public boolean isInProgress() {
			return false;
		}
			return "Redo Text Change";
		}
			return "Undo Text Change";
		}
		public boolean canRedo() {
			return true;
		}
		public void undo() throws CannotUndoException {
			if ( != null) {
			}
			super.undo();
			 = null;
		}
		public void redo() throws CannotRedoException {
			super.redo();
		}
		private void restoreSelections() {
			if (. instanceof DataMap) {
								(DataMap) .,
else if (. instanceof ObjEntity) {
								(ObjEntity) .,
else if (. instanceof DbEntity) {
						new EntityDisplayEvent(this, (DbEntity) .,
			}
		}
	}
		return Application.getInstance().getFrameController()
	}
New to GrepCode? Check out our FAQ X