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.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.query.EJBQLQuery;
 import  org.apache.cayenne.query.SQLTemplate;
 
 public class TextCompoundEdit extends CompoundEdit implements DocumentListener {
 
     private TextAdapter adapter;
     private JTextComponent editor;
 
     private TreePath treePath;
     private int selectedTabIndex;
     private JTabbedPane tabbedPane;
 
     private Object targetObject;
 
     private JTextFieldUndoListener listener;
 
     public Object getTargetObject() {
         return ;
     }
 
     public TextCompoundEdit(TextAdapter adapterJTextFieldUndoListener listener) {
         this(adapter.getComponent(), listener);
         this. = adapter;
     }
 
     public TextCompoundEdit(JTextComponent editorJTextFieldUndoListener listener) {
 
         this. = editor;
         this. = listener;
 
         EditorView editorView = ((CayenneModelerFrame) Application
                 .getInstance()
                 .getFrameController()
                 .getView()).getView();
 
          = editorView.getProjectTreeView().getSelectionPath();
 
         DefaultMutableTreeNode newPath = (DefaultMutableTreeNode
                 .getLastPathComponent();
 
          = newPath.getUserObject();
 
         if ( instanceof ObjEntity) {
              = editorView.getObjDetailView();
         }
 
         if ( instanceof DbEntity) {
              = editorView.getDbDetailView();
         }
 
         if ( instanceof Embeddable) {
              = editorView.getEmbeddableView();
         }
 
         if ( instanceof SQLTemplate) {
              = editorView.getSqlTemplateView();
         }
 
         if ( instanceof EJBQLQuery) {
             = editorView.getEjbqlQueryView();
        }
        if ( instanceof DataNode) {
             = editorView.getDataNodeView();
        }
        if ( instanceof DataMap) {
             = editorView.getDataMapView();
        }
        if ( != null) {
             = .getSelectedIndex();
        }
    }
    private void restoreSelections() {
        EditorView editorView = ((CayenneModelerFrame) Application
                .getInstance()
                .getFrameController()
                .getView()).getView();
        if ( != null) {
        }
    }
    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());
                .setCaretPosition(offset);
            }
        });
    }
    public void removeUpdate(DocumentEvent e) {
        .setCaretPosition(e.getOffset());
    }
    public void changedUpdate(DocumentEvent e) {
    }
    public boolean isInProgress() {
        return false;
    }
    @Override
    public void redo() throws CannotRedoException {
        restoreSelections();
        if (canRedo()) {
            super.redo();
        }
        else {
            die();
        }
        .requestFocusInWindow();
    }
    public void undo() throws CannotUndoException {
        restoreSelections();
        .finishCurrentEdit();
        if (canUndo()) {
            super.undo();
        }
        else {
            die();
        }
        if ( != null) {
            .updateModel();
        }
        .requestFocusInWindow();
        .selectAll();
    }
    @Override
    public synchronized String getRedoPresentationName() {
        return "Redo Text Change";
    }
    @Override
    public synchronized String getUndoPresentationName() {
        return "Undo Text Change";
    }
    public JTextComponent getEditor() {
        return ;
    }
    public void watchCaretPosition() {
        .getDocument().addDocumentListener(this);
    }
    public void stopWatchingCaretPosition() {
    }
New to GrepCode? Check out our FAQ X