当前位置: 首页>>代码示例>>Java>>正文


Java IDocumentUndoManager.transferUndoHistory方法代码示例

本文整理汇总了Java中org.eclipse.text.undo.IDocumentUndoManager.transferUndoHistory方法的典型用法代码示例。如果您正苦于以下问题:Java IDocumentUndoManager.transferUndoHistory方法的具体用法?Java IDocumentUndoManager.transferUndoHistory怎么用?Java IDocumentUndoManager.transferUndoHistory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.text.undo.IDocumentUndoManager的用法示例。


在下文中一共展示了IDocumentUndoManager.transferUndoHistory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: elementMoved

import org.eclipse.text.undo.IDocumentUndoManager; //导入方法依赖的package包/类
@Override
public void elementMoved(final Object originalElement, final Object movedElement) {
    if (originalElement != null && originalElement.equals(editorPart.getEditorInput())) {
        final boolean doValidationAsync = Display.getCurrent() != null;
        final Runnable r = new Runnable() {
            @Override
            public void run() {
                if (movedElement == null || movedElement instanceof IEditorInput) {

                    final String previousContent;
                    IDocumentUndoManager previousUndoManager = null;
                    IDocument changed = null;
                    final boolean wasDirty = editorPart.isDirty();
                    changed = documentProvider.getDocument(editorPart.getEditorInput());
                    if (changed != null) {
                        if (wasDirty)
                            previousContent = changed.get();
                        else
                            previousContent = null;

                        previousUndoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(changed);
                        if (previousUndoManager != null)
                            previousUndoManager.connect(this);
                    } else
                        previousContent = null;

                    editorPart.setInputWithNotify((IEditorInput) movedElement);

                    if (previousUndoManager != null) {
                        final IDocument newDocument = documentProvider.getDocument(movedElement);
                        if (newDocument != null) {
                            final IDocumentUndoManager newUndoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(newDocument);
                            if (newUndoManager != null)
                                newUndoManager.transferUndoHistory(previousUndoManager);
                        }
                        previousUndoManager.disconnect(this);
                    }

                    if (wasDirty && changed != null) {
                        final Runnable r2 = new Runnable() {
                            @Override
                            public void run() {
                                documentProvider.getDocument(editorPart.getEditorInput()).set(previousContent);

                            }
                        };
                        execute(r2, doValidationAsync);
                    }

                }
            }
        };
        execute(r, false);
    }
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:56,代码来源:ERDiagramElementStateListener.java

示例2: elementMoved

import org.eclipse.text.undo.IDocumentUndoManager; //导入方法依赖的package包/类
@Override
public void elementMoved(final Object originalElement, final Object movedElement) {
    if (originalElement != null && originalElement.equals(getEditorInput())) {
        final boolean doValidationAsync = Display.getCurrent() != null;
        final Runnable r = new Runnable() {
            @Override
            public void run() {
                enableSanityChecking(true);

                if (fSourceViewer == null)
                    return;

                if (movedElement == null || movedElement instanceof IEditorInput) {

                    final IDocumentProvider d = getDocumentProvider();
                    final String previousContent;
                    IDocumentUndoManager previousUndoManager = null;
                    IDocument changed = null;
                    final boolean wasDirty = isDirty();
                    changed = d.getDocument(getEditorInput());
                    if (changed != null) {
                        if (wasDirty)
                            previousContent = changed.get();
                        else
                            previousContent = null;

                        previousUndoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(changed);
                        if (previousUndoManager != null)
                            previousUndoManager.connect(this);
                    } else
                        previousContent = null;

                    setInput((IEditorInput) movedElement);

                    // The undo manager needs to be replaced with one
                    // for the new document.
                    // Transfer the undo history and then disconnect
                    // from the old undo manager.
                    if (previousUndoManager != null) {
                        final IDocument newDocument = getDocumentProvider().getDocument(movedElement);
                        if (newDocument != null) {
                            final IDocumentUndoManager newUndoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(newDocument);
                            if (newUndoManager != null)
                                newUndoManager.transferUndoHistory(previousUndoManager);
                        }
                        previousUndoManager.disconnect(this);
                    }

                    if (wasDirty && changed != null) {
                        final Runnable r2 = new Runnable() {
                            @Override
                            public void run() {
                                validateState(getEditorInput());
                                d.getDocument(getEditorInput()).set(previousContent);

                            }
                        };
                        execute(r2, doValidationAsync);
                    }

                }
            }
        };
        execute(r, false);
    }
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:67,代码来源:TestEditor.java

示例3: elementMoved

import org.eclipse.text.undo.IDocumentUndoManager; //导入方法依赖的package包/类
public void elementMoved(final Object originalElement,
		final Object movedElement) {
	if (originalElement != null
			&& originalElement.equals(editorPart.getEditorInput())) {
		final boolean doValidationAsync = Display.getCurrent() != null;
		Runnable r = new Runnable() {
			public void run() {
				if (movedElement == null
						|| movedElement instanceof IEditorInput) {

					final String previousContent;
					IDocumentUndoManager previousUndoManager = null;
					IDocument changed = null;
					boolean wasDirty = editorPart.isDirty();
					changed = documentProvider.getDocument(editorPart
							.getEditorInput());
					if (changed != null) {
						if (wasDirty)
							previousContent = changed.get();
						else
							previousContent = null;

						previousUndoManager = DocumentUndoManagerRegistry
								.getDocumentUndoManager(changed);
						if (previousUndoManager != null)
							previousUndoManager.connect(this);
					} else
						previousContent = null;

					editorPart
							.setInputWithNotify((IEditorInput) movedElement);

					if (previousUndoManager != null) {
						IDocument newDocument = documentProvider
								.getDocument(movedElement);
						if (newDocument != null) {
							IDocumentUndoManager newUndoManager = DocumentUndoManagerRegistry
									.getDocumentUndoManager(newDocument);
							if (newUndoManager != null)
								newUndoManager
										.transferUndoHistory(previousUndoManager);
						}
						previousUndoManager.disconnect(this);
					}

					if (wasDirty && changed != null) {
						Runnable r2 = new Runnable() {
							public void run() {
								documentProvider.getDocument(
										editorPart.getEditorInput()).set(
										previousContent);

							}
						};
						execute(r2, doValidationAsync);
					}

				}
			}
		};
		execute(r, false);
	}
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:64,代码来源:ERDiagramElementStateListener.java

示例4: elementMoved

import org.eclipse.text.undo.IDocumentUndoManager; //导入方法依赖的package包/类
public void elementMoved(final Object originalElement,
		final Object movedElement) {
	if (originalElement != null
			&& originalElement.equals(getEditorInput())) {
		final boolean doValidationAsync = Display.getCurrent() != null;
		Runnable r = new Runnable() {
			public void run() {
				enableSanityChecking(true);

				if (fSourceViewer == null)
					return;

				if (movedElement == null
						|| movedElement instanceof IEditorInput) {

					final IDocumentProvider d = getDocumentProvider();
					final String previousContent;
					IDocumentUndoManager previousUndoManager = null;
					IDocument changed = null;
					boolean wasDirty = isDirty();
					changed = d.getDocument(getEditorInput());
					if (changed != null) {
						if (wasDirty)
							previousContent = changed.get();
						else
							previousContent = null;

						previousUndoManager = DocumentUndoManagerRegistry
								.getDocumentUndoManager(changed);
						if (previousUndoManager != null)
							previousUndoManager.connect(this);
					} else
						previousContent = null;

					setInput((IEditorInput) movedElement);

					// The undo manager needs to be replaced with one
					// for the new document.
					// Transfer the undo history and then disconnect
					// from the old undo manager.
					if (previousUndoManager != null) {
						IDocument newDocument = getDocumentProvider()
								.getDocument(movedElement);
						if (newDocument != null) {
							IDocumentUndoManager newUndoManager = DocumentUndoManagerRegistry
									.getDocumentUndoManager(newDocument);
							if (newUndoManager != null)
								newUndoManager
										.transferUndoHistory(previousUndoManager);
						}
						previousUndoManager.disconnect(this);
					}

					if (wasDirty && changed != null) {
						Runnable r2 = new Runnable() {
							public void run() {
								validateState(getEditorInput());
								d.getDocument(getEditorInput()).set(
										previousContent);

							}
						};
						execute(r2, doValidationAsync);
					}

				}
			}
		};
		execute(r, false);
	}
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:72,代码来源:TestEditor.java

示例5: elementMoved

import org.eclipse.text.undo.IDocumentUndoManager; //导入方法依赖的package包/类
@Override
public void elementMoved(final Object originalElement, final Object movedElement) {
    if (originalElement != null && originalElement.equals(editorPart.getEditorInput())) {
        final boolean doValidationAsync = Display.getCurrent() != null;
        final Runnable r = new Runnable() {

            @Override
            public void run() {
                if (movedElement == null || movedElement instanceof IEditorInput) {
                    final String previousContent;
                    IDocumentUndoManager previousUndoManager = null;
                    IDocument changed = null;
                    final boolean wasDirty = editorPart.isDirty();
                    changed = documentProvider.getDocument(editorPart.getEditorInput());
                    if (changed != null) {
                        if (wasDirty) {
                            previousContent = changed.get();
                        } else {
                            previousContent = null;
                        }
                        previousUndoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(changed);
                        if (previousUndoManager != null) {
                            previousUndoManager.connect(this);
                        }
                    } else {
                        previousContent = null;
                    }
                    editorPart.setInputWithNotify((IEditorInput) movedElement);

                    if (previousUndoManager != null) {
                        final IDocument newDocument = documentProvider.getDocument(movedElement);
                        if (newDocument != null) {
                            final IDocumentUndoManager newUndoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(newDocument);
                            if (newUndoManager != null)
                                newUndoManager.transferUndoHistory(previousUndoManager);
                        }
                        previousUndoManager.disconnect(this);
                    }

                    if (wasDirty && changed != null) {
                        final Runnable r2 = new Runnable() {

                            @Override
                            public void run() {
                                documentProvider.getDocument(editorPart.getEditorInput()).set(previousContent);
                            }
                        };
                        execute(r2, doValidationAsync);
                    }
                }
            }
        };
        execute(r, false);
    }
}
 
开发者ID:dbflute-session,项目名称:erflute,代码行数:56,代码来源:ERDiagramElementStateListener.java


注:本文中的org.eclipse.text.undo.IDocumentUndoManager.transferUndoHistory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。