cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From and...@apache.org
Subject svn commit: r888812 [2/2] - in /cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne: modeler/ modeler/action/ modeler/dialog/ modeler/editor/ modeler/editor/datanode/ modeler/undo/ modeler/util/ swing/ swing/components/textpane/
Date Wed, 09 Dec 2009 14:41:28 GMT
Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JTextFieldUndoListener.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JTextFieldUndoListener.java?rev=888812&r1=888811&r2=888812&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JTextFieldUndoListener.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JTextFieldUndoListener.java
Wed Dec  9 14:41:26 2009
@@ -18,253 +18,88 @@
  ****************************************************************/
 package org.apache.cayenne.modeler.undo;
 
+import java.awt.event.FocusAdapter;
 import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
 
-import javax.swing.SwingUtilities;
 import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
 import javax.swing.event.UndoableEditEvent;
 import javax.swing.event.UndoableEditListener;
 import javax.swing.text.AbstractDocument;
 import javax.swing.text.JTextComponent;
-import javax.swing.tree.TreePath;
-import javax.swing.undo.CannotRedoException;
-import javax.swing.undo.CannotUndoException;
 import javax.swing.undo.CompoundEdit;
-import javax.swing.undo.UndoManager;
 import javax.swing.undo.UndoableEdit;
 
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.modeler.Application;
-import org.apache.cayenne.modeler.CayenneModelerFrame;
-import org.apache.cayenne.modeler.ProjectController;
-import org.apache.cayenne.modeler.event.DataMapDisplayEvent;
-import org.apache.cayenne.modeler.event.EntityDisplayEvent;
+import org.apache.cayenne.modeler.util.TextAdapter;
 
 public class JTextFieldUndoListener implements UndoableEditListener {
 
-	private UndoManager undoManager;
-	private CompoundEdit compoundEdit;
-	private JTextComponent textComponent;
-	private UndoDocumentListener undoDocumentListener;
+    public CompoundEdit compoundEdit;
+    
+    private TextAdapter adapter;
+
+    private int lastOffset;
+    private int lastLength;
+
+    public JTextFieldUndoListener(TextAdapter adapter) {
+        this.adapter = adapter;
+
+        this.adapter.getComponent().addFocusListener(new FocusAdapter() {
+
+            @Override
+            public void focusLost(FocusEvent e) {
+                if (compoundEdit != null) {
+                    compoundEdit.end();
+                    compoundEdit = null;
+                }
+            }
+        });
+    }
+
+    public void undoableEditHappened(UndoableEditEvent e) {
+        
+        JTextComponent editor = adapter.getComponent();
+        
+        if (compoundEdit == null || !compoundEdit.canUndo()) {
+            compoundEdit = startCompoundEdit(e.getEdit());
+            lastLength = editor.getDocument().getLength();
+            return;
+        }
+
+        AbstractDocument.DefaultDocumentEvent event = (AbstractDocument.DefaultDocumentEvent)
e
+                .getEdit();
+
+        if (event.getType().equals(DocumentEvent.EventType.CHANGE)) {
+            compoundEdit.addEdit(e.getEdit());
+            return;
+        }
+
+        int offsetChange = editor.getCaretPosition() - lastOffset;
+        int lengthChange = editor.getDocument().getLength() - lastLength;
+
+        if (Math.abs(offsetChange) == 1 && Math.abs(lengthChange) == 1) {
+            compoundEdit.addEdit(e.getEdit());
+            lastOffset = editor.getCaretPosition();
+            lastLength = editor.getDocument().getLength();
+            return;
+        }
+
+        compoundEdit.end();
+        compoundEdit = startCompoundEdit(e.getEdit());
+    }
+
+    private CompoundEdit startCompoundEdit(UndoableEdit anEdit) {
+        
+        JTextComponent editor = adapter.getComponent();
+        
+        lastOffset = editor.getCaretPosition();
+        lastLength = editor.getDocument().getLength();
 
-	private Object currentObj;
-	private TreePath[] paths;
+        compoundEdit = new TextCompoundEdit(adapter);
+        compoundEdit.addEdit(anEdit);
 
-	private int lastOffset;
-	private int lastLength;
+        Application.getInstance().getUndoManager().addEdit(compoundEdit);
 
-	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, textComponent.getDocument()
-							.getLength());
-					textComponent.setCaretPosition(offset);
-				}
-			});
-		}
-
-		public void removeUpdate(DocumentEvent e) {
-			textComponent.setCaretPosition(e.getOffset());
-		}
-
-	}
-
-	public JTextFieldUndoListener(JTextComponent textComponent) {
-		this.textComponent = textComponent;
-		this.undoManager = Application.getInstance().getUndoManager();
-		this.undoDocumentListener = new UndoDocumentListener();
-
-		this.textComponent.addFocusListener(new FocusListener() {
-
-			public void focusGained(FocusEvent e) {
-				if (self.currentObj == null) {
-					self.currentObj = getProjectController().getCurrentObject();
-					self.paths = ((CayenneModelerFrame) Application
-							.getInstance().getFrameController().getView())
-							.getView().getProjectTreeView().getSelectionPaths();
-				}
-			}
-
-			public void focusLost(FocusEvent e) {
-				self.currentObj = null;
-
-				if (compoundEdit != null) {
-					compoundEdit.end();
-					compoundEdit = null;
-				}
-			}
-
-		});
-
-		this.textComponent.addKeyListener(new KeyListener() {
-
-			public void keyPressed(KeyEvent e) {
-				inProgress = true;
-			}
-
-			public void keyReleased(KeyEvent e) {
-			}
-
-			public void keyTyped(KeyEvent e) {
-			}
-
-		});
-
-	}
-
-	public void undoableEditHappened(UndoableEditEvent e) {
-		if (inProgress) {
-			if (compoundEdit == null) {
-				compoundEdit = startCompoundEdit(e.getEdit());
-			} else {
-				AbstractDocument.DefaultDocumentEvent event = (AbstractDocument.DefaultDocumentEvent)
e
-						.getEdit();
-
-				if (event.getType().equals(DocumentEvent.EventType.CHANGE)) {
-					compoundEdit.addEdit(e.getEdit());
-					return;
-				}
-
-				int offsetChange = textComponent.getCaretPosition()
-						- lastOffset;
-				int lengthChange = textComponent.getDocument().getLength()
-						- lastLength;
-
-				if (offsetChange == lengthChange && Math.abs(offsetChange) == 1) {
-					compoundEdit.addEdit(e.getEdit());
-					lastOffset = textComponent.getCaretPosition();
-					lastLength = textComponent.getDocument().getLength();
-					return;
-				} else {
-					compoundEdit.end();
-					compoundEdit = startCompoundEdit(e.getEdit());
-				}
-			}
-
-			inProgress = !inProgress;
-		}
-	}
-
-	private CompoundEdit startCompoundEdit(UndoableEdit e) {
-		lastOffset = textComponent.getCaretPosition();
-		lastLength = textComponent.getDocument().getLength();
-
-		CompoundEdit compoundEdit = new TextCompoundEdit();
-		compoundEdit.addEdit(e);
-
-		undoManager.addEdit(compoundEdit);
-
-		return compoundEdit;
-	}
-
-	private class TextCompoundEdit extends CompoundEdit {
-		
-
-		public boolean isInProgress() {
-			return false;
-		}
-
-		@Override
-		public String getRedoPresentationName() {
-			return "Redo Text Change";
-		}
-
-		@Override
-		public String getUndoPresentationName() {
-			return "Undo Text Change";
-		}
-
-		@Override
-		public boolean canRedo() {
-			return true;
-		}
-
-		public void undo() throws CannotUndoException {
-			textComponent.getDocument().addDocumentListener(
-					undoDocumentListener);
-
-			if (compoundEdit != null) {
-				compoundEdit.end();
-			}
-
-			restoreSelections();
-
-			super.undo();
-
-			compoundEdit = null;
-
-			textComponent.getDocument().removeDocumentListener(
-					undoDocumentListener);
-
-			textComponent.requestFocusInWindow();
-			textComponent.selectAll();
-		}
-
-		public void redo() throws CannotRedoException {
-			textComponent.getDocument().addDocumentListener(
-					undoDocumentListener);
-
-			super.redo();
-
-			textComponent.getDocument().removeDocumentListener(
-					undoDocumentListener);
-			textComponent.requestFocusInWindow();
-		}
-
-		private void restoreSelections() {
-			((CayenneModelerFrame) Application.getInstance()
-					.getFrameController().getView()).getView()
-					.getProjectTreeView().setSelectionPaths(self.paths);
-
-			if (self.currentObj instanceof DataMap) {
-
-				getProjectController().fireDataMapDisplayEvent(
-						new DataMapDisplayEvent(this,
-								(DataMap) self.currentObj,
-								getProjectController().getCurrentDataDomain(),
-								getProjectController().getCurrentDataNode()));
-
-			} else if (self.currentObj instanceof ObjEntity) {
-
-				getProjectController().fireObjEntityDisplayEvent(
-						new EntityDisplayEvent(this,
-								(ObjEntity) self.currentObj,
-								getProjectController().getCurrentDataMap(),
-								getProjectController().getCurrentDataNode(),
-								getProjectController().getCurrentDataDomain()));
-
-			} else if (self.currentObj instanceof DbEntity) {
-
-				getProjectController().fireDbEntityDisplayEvent(
-						new EntityDisplayEvent(this, (DbEntity) self.currentObj,
-								getProjectController().getCurrentDataMap(),
-								getProjectController().getCurrentDataNode(),
-								getProjectController().getCurrentDataDomain()));
-				
-
-			}
-		}
-	}
-
-	private ProjectController getProjectController() {
-		return Application.getInstance().getFrameController()
-				.getProjectController();
-	}
+        return compoundEdit;
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RelationshipUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RelationshipUndoableEdit.java?rev=888812&r1=888811&r2=888812&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RelationshipUndoableEdit.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RelationshipUndoableEdit.java
Wed Dec  9 14:41:26 2009
@@ -21,15 +21,18 @@
 import javax.swing.undo.AbstractUndoableEdit;
 import javax.swing.undo.CannotRedoException;
 import javax.swing.undo.CannotUndoException;
+import javax.swing.undo.CompoundEdit;
 
 import org.apache.cayenne.map.DbJoin;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.modeler.dialog.ResolveDbRelationshipDialog;
 import org.apache.cayenne.modeler.util.ProjectUtil;
 
-public class RelationshipUndoableEdit extends CayenneCompoundEdit {
+public class RelationshipUndoableEdit extends CompoundEdit {
 
-	@Override
+    private DbRelationship relationship;
+	
+    @Override
 	public void redo() throws CannotRedoException {
 		super.redo();
 		
@@ -59,15 +62,6 @@
 		return "Undo Edit relationship";
 	}
 
-	
-
-	private DbRelationship relationship;
-
-	@Override
-	public boolean canUndo() {
-		return hasEdits();
-	}
-
 	public RelationshipUndoableEdit(DbRelationship relationship) {
 		this.relationship = relationship;
 	}

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveAttributeUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveAttributeUndoableEdit.java?rev=888812&r1=888811&r2=888812&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveAttributeUndoableEdit.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveAttributeUndoableEdit.java
Wed Dec  9 14:41:26 2009
@@ -36,8 +36,6 @@
 
 public class RemoveAttributeUndoableEdit extends CayenneUndoableEdit {
 
-    
-
     private DataDomain domain;
     private DataMap dataMap;
 
@@ -75,8 +73,6 @@
 
     @Override
     public void redo() throws CannotRedoException {
-        restoreSelections();
-
         RemoveAttributeAction action = (RemoveAttributeAction) actionManager
                 .getAction(RemoveAttributeAction.getActionName());
 
@@ -110,7 +106,6 @@
 
     @Override
     public void undo() throws CannotUndoException {
-        restoreSelections();
 
         CreateAttributeAction action = (CreateAttributeAction) actionManager
                 .getAction(CreateAttributeAction.getActionName());

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveCompoundUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveCompoundUndoableEdit.java?rev=888812&r1=888811&r2=888812&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveCompoundUndoableEdit.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveCompoundUndoableEdit.java
Wed Dec  9 14:41:26 2009
@@ -18,10 +18,10 @@
  ****************************************************************/
 package org.apache.cayenne.modeler.undo;
 
+import javax.swing.undo.CompoundEdit;
 
-public class RemoveCompoundUndoableEdit extends CayenneCompoundEdit {
 
-    
+public class RemoveCompoundUndoableEdit extends CompoundEdit {
 
     @Override
     public String getPresentationName() {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveRelationshipUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveRelationshipUndoableEdit.java?rev=888812&r1=888811&r2=888812&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveRelationshipUndoableEdit.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveRelationshipUndoableEdit.java
Wed Dec  9 14:41:26 2009
@@ -30,8 +30,6 @@
 
 public class RemoveRelationshipUndoableEdit extends CayenneUndoableEdit {
 
-	
-
 	private ObjEntity objEntity;
 	private ObjRelationship[] rels;
 
@@ -63,8 +61,6 @@
 
 	@Override
 	public void redo() throws CannotRedoException {
-		restoreSelections();
-		
 		RemoveRelationshipAction action = (RemoveRelationshipAction) actionManager
 				.getAction(RemoveRelationshipAction.getActionName());
 		if (objEntity != null) {
@@ -76,8 +72,6 @@
 
 	@Override
 	public void undo() throws CannotUndoException {
-		restoreSelections();
-		
 		CreateRelationshipAction action = (CreateRelationshipAction) actionManager
 				.getAction(CreateRelationshipAction.getActionName());
 		if (objEntity != null) {

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/TextCompoundEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/TextCompoundEdit.java?rev=888812&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/TextCompoundEdit.java
(added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/TextCompoundEdit.java
Wed Dec  9 14:41:26 2009
@@ -0,0 +1,193 @@
+/*****************************************************************
+ *   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 javax.swing.JTabbedPane;
+import javax.swing.SwingUtilities;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.text.JTextComponent;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreePath;
+import javax.swing.undo.CannotRedoException;
+import javax.swing.undo.CannotUndoException;
+import javax.swing.undo.CompoundEdit;
+
+import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.Embeddable;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.modeler.CayenneModelerFrame;
+import org.apache.cayenne.modeler.editor.EditorView;
+import org.apache.cayenne.modeler.util.TextAdapter;
+import org.apache.cayenne.query.EJBQLQuery;
+import org.apache.cayenne.query.SQLTemplate;
+
+public class TextCompoundEdit extends CompoundEdit implements DocumentListener {
+
+    private TextAdapter adapter;
+
+    private TreePath treePath;
+    private int selectedTabIndex;
+    private JTabbedPane tabbedPane;
+    
+    private Object targetObject;
+
+    public Object getTargetObject() {
+        return targetObject;
+    }
+
+    public TextCompoundEdit(TextAdapter adapter) {
+        this.adapter = adapter;
+
+        EditorView editorView = ((CayenneModelerFrame) Application
+                .getInstance()
+                .getFrameController()
+                .getView()).getView();
+
+        treePath = editorView.getProjectTreeView().getSelectionPath();
+
+        DefaultMutableTreeNode newPath = (DefaultMutableTreeNode) treePath
+                .getLastPathComponent();
+
+        targetObject = newPath.getUserObject();
+
+        if (targetObject instanceof ObjEntity) {
+            tabbedPane = editorView.getObjDetailView();
+        }
+
+        if (targetObject instanceof DbEntity) {
+            tabbedPane = editorView.getDbDetailView();
+        }
+
+        if (targetObject instanceof Embeddable) {
+            tabbedPane = editorView.getEmbeddableView();
+        }
+
+        if (targetObject instanceof SQLTemplate) {
+            tabbedPane = editorView.getSqlTemplateView();
+        }
+
+        if (targetObject instanceof EJBQLQuery) {
+            tabbedPane = editorView.getEjbqlQueryView();
+        }
+
+        if (targetObject instanceof DataNode) {
+            tabbedPane = editorView.getDataNodeView();
+        }
+
+        if (targetObject instanceof DataMap) {
+            tabbedPane = editorView.getDataMapView();
+        }
+
+        if (targetObject instanceof DataDomain) {
+            tabbedPane = editorView.getDataDomainView();
+        }
+
+        if (tabbedPane != null) {
+            selectedTabIndex = tabbedPane.getSelectedIndex();
+        }
+    }
+
+    private void restoreSelections() {
+
+        EditorView editorView = ((CayenneModelerFrame) Application
+                .getInstance()
+                .getFrameController()
+                .getView()).getView();
+
+        editorView.getProjectTreeView().getSelectionModel().setSelectionPath(treePath);
+
+        if (tabbedPane != null) {
+            tabbedPane.setSelectedIndex(selectedTabIndex);
+        }
+    }
+
+    public void insertUpdate(final DocumentEvent e) {
+        SwingUtilities.invokeLater(new Runnable() {
+
+            public void run() {
+                int offset = e.getOffset() + e.getLength();
+                offset = Math.min(offset, adapter
+                        .getComponent()
+                        .getDocument()
+                        .getLength());
+                adapter.getComponent().setCaretPosition(offset);
+            }
+        });
+    }
+
+    public void removeUpdate(DocumentEvent e) {
+        adapter.getComponent().setCaretPosition(e.getOffset());
+    }
+
+    public void changedUpdate(DocumentEvent e) {
+    }
+
+    public boolean isInProgress() {
+        return false;
+    }
+
+    @Override
+    public void redo() throws CannotRedoException {
+        restoreSelections();
+
+        super.redo();
+
+        adapter.getComponent().requestFocusInWindow();
+    }
+
+    public void undo() throws CannotUndoException {
+        restoreSelections();
+
+        end();
+
+        super.undo();
+
+        adapter.updateModel();
+
+        adapter.getComponent().requestFocusInWindow();
+        adapter.getComponent().selectAll();
+    }
+
+    @Override
+    public synchronized String getRedoPresentationName() {
+        return "Redo Text Change";
+    }
+
+    @Override
+    public synchronized String getUndoPresentationName() {
+        return "Undo Text Change";
+    }
+
+    public JTextComponent getEditor() {
+        return adapter.getComponent();
+    }
+
+    public void watchCaretPosition() {
+        adapter.getComponent().getDocument().addDocumentListener(this);
+    }
+
+    public void stopWatchingCaretPosition() {
+        adapter.getComponent().getDocument().removeDocumentListener(this);
+    }
+}
\ No newline at end of file

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneWidgetFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneWidgetFactory.java?rev=888812&r1=888811&r2=888812&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneWidgetFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneWidgetFactory.java
Wed Dec  9 14:41:26 2009
@@ -35,6 +35,7 @@
 import javax.swing.JTextField;
 import javax.swing.SwingConstants;
 import javax.swing.table.TableCellEditor;
+import javax.swing.text.JTextComponent;
 
 import org.apache.cayenne.modeler.ModelerPreferences;
 import org.apache.cayenne.modeler.undo.JComboBoxUndoListener;
@@ -106,22 +107,6 @@
         comboBox.setMaximumRowCount(ModelerPreferences.COMBOBOX_MAX_VISIBLE_SIZE);
         return comboBox;
     }
-    
-    /**
-     * Creates undoable JTextField.
-     * 
-     */
-    public static JTextField createUndoableTextField() {
-        return new JTextFieldUndoable();
-    }
-    
-    /**
-     * Creates undoable JTextField.
-     * 
-     */
-    public static JTextField createUndoableTextField(int size) {
-        return new JTextFieldUndoable(size);
-    }
 
     /**
      * Creates cell editor for text field

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/TextAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/TextAdapter.java?rev=888812&r1=888811&r2=888812&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/TextAdapter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/TextAdapter.java
Wed Dec  9 14:41:26 2009
@@ -25,7 +25,6 @@
 
 import javax.swing.InputVerifier;
 import javax.swing.JComponent;
-import javax.swing.JTextArea;
 import javax.swing.JTextField;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
@@ -33,8 +32,10 @@
 import javax.swing.text.JTextComponent;
 
 import org.apache.cayenne.modeler.dialog.validator.ValidatorDialog;
+import org.apache.cayenne.modeler.undo.JEditTextAreaUndoableAdapter;
 import org.apache.cayenne.modeler.undo.JTextFieldUndoListener;
 import org.apache.cayenne.validation.ValidationException;
+import org.syntax.jedit.JEditTextArea;
 
 /**
  * A validating adapter for JTextComponent. Implement {@link #updateModel(String)}to
@@ -45,11 +46,17 @@
 
     protected Color defaultBGColor;
     protected Color errorColor;
-    protected JTextComponent textComponent;
+
     protected String defaultToolTip;
     protected boolean modelUpdateDisabled;
     protected UndoableEditListener undoableListener;
 
+    protected JTextComponent textComponent;
+
+    public TextAdapter(JEditTextArea textArea) {
+        this(new JEditTextAreaUndoableAdapter(textArea), true, false, true);
+    }
+
     public TextAdapter(JTextField textField) {
         this(textField, true, false, true);
     }
@@ -70,7 +77,7 @@
         }
     }
 
-    public TextAdapter(JTextArea textField) {
+    public TextAdapter(JTextComponent textField) {
         this(textField, false, true);
     }
 
@@ -81,8 +88,8 @@
         this.defaultBGColor = textComponent.getBackground();
         this.defaultToolTip = textComponent.getToolTipText();
         this.textComponent = textComponent;
-        
-        this.undoableListener = new JTextFieldUndoListener(this.textComponent);
+
+        this.undoableListener = new JTextFieldUndoListener(this);
         this.textComponent.getDocument().addUndoableEditListener(this.undoableListener);
 
         if (checkOnFocusLost) {
@@ -154,7 +161,7 @@
 
     }
 
-    protected void updateModel() {
+    public void updateModel() {
         try {
             updateModel(textComponent.getText());
             clear();

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/swing/BindingBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/swing/BindingBuilder.java?rev=888812&r1=888811&r2=888812&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/swing/BindingBuilder.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/swing/BindingBuilder.java
Wed Dec  9 14:41:26 2009
@@ -24,6 +24,7 @@
 import java.util.Map;
 
 import javax.swing.*;
+import javax.swing.text.JTextComponent;
 
 /**
  * A builder for component bindings that delegates the creation of the binding to the

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/swing/components/textpane/JCayenneTextPane.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/swing/components/textpane/JCayenneTextPane.java?rev=888812&r1=888811&r2=888812&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/swing/components/textpane/JCayenneTextPane.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/swing/components/textpane/JCayenneTextPane.java
Wed Dec  9 14:41:26 2009
@@ -1,7 +1,6 @@
 package org.apache.cayenne.swing.components.textpane;
 
 import java.awt.Color;
-import java.awt.Component;
 import java.awt.Cursor;
 import java.awt.Dimension;
 import java.awt.Graphics;
@@ -20,6 +19,7 @@
 import javax.swing.text.BadLocationException;
 import javax.swing.text.Document;
 import javax.swing.text.Highlighter;
+import javax.swing.text.JTextComponent;
 
 import org.apache.cayenne.modeler.Main;
 import org.apache.cayenne.modeler.util.ModelerUtil;
@@ -63,7 +63,7 @@
         return pane.getText();
     }
 
-    public Component getPane() {
+    public JTextComponent getPane() {
         return pane;
     }
 



Mime
View raw message