• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DocumentUndoManagerRegistry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



DocumentUndoManagerRegistry类属于org.eclipse.text.undo包,在下文中一共展示了DocumentUndoManagerRegistry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: applyEdits

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的package包/类
/**
 * Method will apply all edits to document as single modification. Needs to
 * be executed in UI thread.
 *
 * @param document
 *            document to modify
 * @param edits
 *            list of LSP TextEdits
 */
public static void applyEdits(IDocument document, TextEdit edit) {
	if (document == null) {
		return;
	}

	IDocumentUndoManager manager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
	if (manager != null) {
		manager.beginCompoundChange();
	}
	try {
		RewriteSessionEditProcessor editProcessor = new RewriteSessionEditProcessor(document, edit,
				org.eclipse.text.edits.TextEdit.NONE);
		editProcessor.performEdits();
	} catch (MalformedTreeException | BadLocationException e) {
		EditorConfigPlugin.logError(e);
	}
	if (manager != null) {
		manager.endCompoundChange();
	}
}
 
开发者ID:angelozerr,项目名称:ec4e,代码行数:30,代码来源:MarkerUtils.java


示例2: removeComment

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的package包/类
private void removeComment(IDocument doc, int offset) {
	try {
		IDocumentUndoManager undoMgr = DocumentUndoManagerRegistry.getDocumentUndoManager(doc);
		undoMgr.beginCompoundChange();

		ITypedRegion par = TextUtilities.getPartition(doc, Partitions.MK_PARTITIONING, offset, false);
		int beg = par.getOffset();
		int len = par.getLength();

		String comment = doc.get(beg, len);
		int eLen = markerLen(comment);
		int bLen = eLen + 1;

		MultiTextEdit edit = new MultiTextEdit();
		edit.addChild(new DeleteEdit(beg, bLen));
		edit.addChild(new DeleteEdit(beg + len - eLen, eLen));
		edit.apply(doc);
		undoMgr.endCompoundChange();
	} catch (MalformedTreeException | BadLocationException e) {
		Log.error("Failure removing comment " + e.getMessage());
	}
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:23,代码来源:ToggleHiddenCommentHandler.java


示例3: applyEdits

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的package包/类
/**
 * Method will apply all edits to document as single modification. Needs to
 * be executed in UI thread.
 * 
 * @param document
 *            document to modify
 * @param edits
 *            list of TypeScript {@link CodeEdit}.
 * @throws TypeScriptException
 * @throws BadLocationException
 * @throws MalformedTreeException
 */
public static void applyEdits(IDocument document, List<CodeEdit> codeEdits)
		throws TypeScriptException, MalformedTreeException, BadLocationException {
	if (document == null || codeEdits.isEmpty()) {
		return;
	}

	IDocumentUndoManager manager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
	if (manager != null) {
		manager.beginCompoundChange();
	}

	try {
		TextEdit edit = toTextEdit(codeEdits, document);
		// RewriteSessionEditProcessor editProcessor = new
		// RewriteSessionEditProcessor(document, edit,
		// org.eclipse.text.edits.TextEdit.NONE);
		// editProcessor.performEdits();
		edit.apply(document);
	} finally {
		if (manager != null) {
			manager.endCompoundChange();
		}
	}
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:37,代码来源:DocumentUtils.java


示例4: installUndoRedoSupport

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的package包/类
protected OperationHistoryListener installUndoRedoSupport(SourceViewer viewer, IDocument document, final EmbeddedEditorActions actions) {
			IDocumentUndoManager undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
			final IUndoContext context = undoManager.getUndoContext();
			
			// XXX cp uncommented
			
//			IOperationHistory operationHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
			OperationHistoryListener operationHistoryListener = new OperationHistoryListener(context, new IUpdate() {
				public void update() {
					actions.updateAction(ITextEditorActionConstants.REDO);
					actions.updateAction(ITextEditorActionConstants.UNDO);
				}
			});
			viewer.addTextListener(new ITextListener() {
				
				public void textChanged(TextEvent event) {
					actions.updateAction(ITextEditorActionConstants.REDO);
					actions.updateAction(ITextEditorActionConstants.UNDO);
					
				}
			});
//			
//			operationHistory.addOperationHistoryListener(operationHistoryListener);
			return operationHistoryListener;
		}
 
开发者ID:cplutte,项目名称:bts,代码行数:26,代码来源:EmbeddedEditorFactory.java


示例5: replaceAll

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的package包/类
/**
 * Replace all occurrences
 */
private void replaceAll() {
	boolean allState = isReplaceAll(); 
	IDocumentUndoManager undoer = DocumentUndoManagerRegistry.getDocumentUndoManager(getDocument());
	try {
		paused = false;
		setReplaceAll(true);	// force flag so we don't re-enter the undoer during case replacement
		if (undoer != null) {
			undoer.beginCompoundChange();
		}
		replaceIt();
		while (findNext(getSearchStr())){
			replaceIt();
		}
	} finally {
		setReplaceAll(allState);
		if (undoer != null) {
			undoer.endCompoundChange();
		}
	}
	finish();
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:25,代码来源:SearchReplaceMinibuffer.java


示例6: register

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的package包/类
/**
 * Registers a document manager with an editor.
 * @param doc the document to be managed
 * @param st the styled text of the editor
 * @param dm the document manager
 */
public static void register(IDocument doc, StyledText st, DocumentManager dm) {
    if (doc != null) {
        doc.addDocumentListener(dm);
        
        DocumentUndoManagerRegistry.connect(doc);
        IDocumentUndoManager undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(doc);
        if (undoManager != null) {
            undoManager.addDocumentUndoListener(dm);
        }
    }
    
    if (st != null) {
        st.addListener(SWT.KeyDown, dm);
        st.addListener(SWT.MouseDown, dm);
        st.addListener(SWT.MouseDoubleClick, dm);
    }
}
 
开发者ID:liaoziyang,项目名称:ContentAssist,代码行数:24,代码来源:DocumentManager.java


示例7: unregister

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的package包/类
/**
 * Unregisters a document manager with an editor.
 * @param doc the document to be managed
 * @param st the styled text of the editor
 * @param dm the document manager
 */
public static void unregister(IDocument doc, StyledText st, DocumentManager dm) {
    if (doc != null) {
        doc.removeDocumentListener(dm);
        
        IDocumentUndoManager undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(doc);
        DocumentUndoManagerRegistry.disconnect(doc);
        if (undoManager != null) {
            undoManager.removeDocumentUndoListener(dm);
        }
    }
    
    if (st != null) {
        st.removeListener(SWT.KeyDown, dm);
        st.removeListener(SWT.MouseDown, dm);
        st.removeListener(SWT.MouseDoubleClick, dm);
    }
}
 
开发者ID:liaoziyang,项目名称:ContentAssist,代码行数:24,代码来源:DocumentManager.java


示例8: format

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的package包/类
public static void format(FluentMkEditor editor, ITextSelection sel) {
	IDocument doc = editor.getDocument();
	if (doc == null || doc.getLength() == 0) return;
	docLength = doc.getLength();

	IPreferenceStore store = editor.getPrefsStore();
	cols = store.getInt(Prefs.EDITOR_FORMATTING_COLUMN);
	tabWidth = store.getInt(Prefs.EDITOR_TAB_WIDTH);

	try {
		PageRoot model = editor.getPageModel();
		List<PagePart> parts = model.getPageParts();
		if (sel != null && sel.getLength() > 0) {
			parts = selectedParts(model, sel);
		}

		IDocumentUndoManager undoMgr = DocumentUndoManagerRegistry.getDocumentUndoManager(doc);
		undoMgr.beginCompoundChange();
		TextEdit edit = new MultiTextEdit();
		for (PagePart part : parts) {
			formatPagePart(part, edit);
		}
		edit.apply(editor.getDocument());
		undoMgr.endCompoundChange();
	} catch (Exception ex) {
		Log.error("Bad location error occurred during formatting", ex);
	}
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:29,代码来源:MkFormatter.java


示例9: remove

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的package包/类
private void remove(int beg, int len, int markLen) {
	try {
		IDocumentUndoManager undoMgr = DocumentUndoManagerRegistry.getDocumentUndoManager(doc);
		undoMgr.beginCompoundChange();

		MultiTextEdit edit = new MultiTextEdit();
		edit.addChild(new DeleteEdit(beg - markLen, markLen));
		edit.addChild(new DeleteEdit(beg + len, markLen));
		edit.apply(doc);
		undoMgr.endCompoundChange();
	} catch (MalformedTreeException | BadLocationException e) {
		Log.error("Failure removing mark" + e.getMessage());
	}
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:15,代码来源:AbstractMarksHandler.java


示例10: addComment

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的package包/类
private void addComment(IDocument doc, int beg, int len) {
	IDocumentUndoManager undoMgr = DocumentUndoManagerRegistry.getDocumentUndoManager(doc);
	undoMgr.beginCompoundChange();

	MultiTextEdit edit = new MultiTextEdit();
	edit.addChild(new InsertEdit(beg, getCommentBeg()));
	edit.addChild(new InsertEdit(beg + len, getCommentEnd()));
	try {
		edit.apply(doc);
		undoMgr.endCompoundChange();
	} catch (MalformedTreeException | BadLocationException e) {
		Log.error("Failure creating comment " + e.getMessage());
	}
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:15,代码来源:ToggleHiddenCommentHandler.java


示例11: doSave

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的package包/类
@Override
public void doSave(IProgressMonitor progressMonitor) {
	IDocument doc = getDocumentProvider().getDocument(getEditorInput());
	if (doc != null) {
		IDocumentUndoManager undoMgr = DocumentUndoManagerRegistry.getDocumentUndoManager(doc);
		if (undoMgr != null) undoMgr.commit();
	}
	super.doSave(progressMonitor);
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:10,代码来源:FluentMkEditor.java


示例12: setUpUndo

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的package包/类
protected void setUpUndo(TextConsoleViewer viewer) {
		 IDocumentUndoManager undoer = DocumentUndoManagerRegistry.getDocumentUndoManager(viewer.getDocument());
		 if (undoer == null) {
			 DocumentUndoManagerRegistry.connect(viewer.getDocument());
//			 undoer = DocumentUndoManagerRegistry.getDocumentUndoManager(viewer.getDocument());
//			 viewer.setUndoManager((IUndoManager) undoer);
		 }
	}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:9,代码来源:ConsoleCmdHandler.java


示例13: caseReplace

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的package包/类
/**
 * Case-based replacement - after the initial find has already happened
 * 
 * @param replacer - the replacement string (may be regexp)
 * @param index - offset of find
 * @param all - all if true, else initial
 * @return - the replacement region
 * 
 * @throws BadLocationException
 */
private IRegion caseReplace(String replacer, int index, boolean all) throws BadLocationException {
	IRegion result = null;
	IDocumentUndoManager undoer = DocumentUndoManagerRegistry.getDocumentUndoManager(getDocument());
	try {
		if (!isReplaceAll() && undoer != null) {
			undoer.beginCompoundChange();
		}
		IFindReplaceTarget target = getTarget();
		// first replace with (possible regexp) string
		((IFindReplaceTargetExtension3)target).replaceSelection(replacer, isRegexp());
		// adjust case of actual replacement string
		replacer = target.getSelectionText();
		String caseReplacer = replacer;
		if (all) {
			caseReplacer = caseReplacer.toUpperCase();
		} else {
			caseReplacer = caseReplacer.trim();
			caseReplacer = Character.toUpperCase(caseReplacer.charAt(0)) + 
			caseReplacer.substring(1,caseReplacer.length()).toString();
			// now update the replacement string with the re-cased part
			caseReplacer = replacer.replaceFirst(replacer.trim(), caseReplacer);
		}
		int ind = target.findAndSelect(index, replacer, true, false, false);
		if (ind > -1) {
			target.replaceSelection(caseReplacer);
		}
	}  finally {
		if (!isReplaceAll() && undoer != null) {
			undoer.endCompoundChange();
		}
	}
	return result;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:44,代码来源:SearchReplaceMinibuffer.java


示例14: elementMoved

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的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


示例15: elementMoved

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的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


示例16: elementMoved

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的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


示例17: elementMoved

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的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


示例18: toggle

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的package包/类
private void toggle(int beg, int len) {
	// if surrounded by marks, remove them
	String mark = isMarked(beg, len);
	if (qualified(mark)) {
		remove(beg, len, mark.length());
		return;
	}

	if (mark == null || mark.charAt(0) == markSpec[1].charAt(0)) {
		mark = markSpec[0];
	} else {
		mark = markSpec[1];
	}

	// add surrounding marks
	IDocumentUndoManager undoMgr = DocumentUndoManagerRegistry.getDocumentUndoManager(doc);
	undoMgr.beginCompoundChange();
	MultiTextEdit edit = new MultiTextEdit();
	edit.addChild(new InsertEdit(beg, mark));
	edit.addChild(new InsertEdit(beg + len, mark));

	// // remove any included marks
	// if (len > 0) {
	// try {
	// String text = doc.get(beg, len);
	// Pattern srch = Pattern.compile(Pattern.quote(markSpec[0]));
	// Matcher matcher = srch.matcher(text);
	// while (matcher.find()) {
	// int start = matcher.start();
	// int stop = matcher.end();
	// edit.addChild(new DeleteEdit(beg + start, stop - start + 1));
	// }
	// } catch (MalformedTreeException | BadLocationException e) {}
	// }

	try {
		edit.apply(doc);
		undoMgr.endCompoundChange();
		editor.setCursorOffset(cpos + markSpec[0].length());
	} catch (MalformedTreeException | BadLocationException e) {
		Log.error("Failure applying mark" + e.getMessage());
	}
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:44,代码来源:AbstractMarksHandler.java


示例19: elementMoved

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的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


示例20: createPartControl

import org.eclipse.text.undo.DocumentUndoManagerRegistry; //导入依赖的package包/类
public void createPartControl( Composite parent )
{
	Composite child = this.initEditorLayout( parent );

	// Script combo
	cmbExprListViewer = new ComboViewer( cmbExpList );
	JSExpListProvider provider = new JSExpListProvider( );
	cmbExprListViewer.setContentProvider( provider );
	cmbExprListViewer.setLabelProvider( provider );
	cmbExprListViewer.setData( VIEWER_CATEGORY_KEY, VIEWER_CATEGORY_CONTEXT );

	// SubFunctions combo
	JSSubFunctionListProvider subProvider = new JSSubFunctionListProvider( this );

	// also add subProvider as listener of expr viewer.
	cmbExprListViewer.addSelectionChangedListener( subProvider );

	cmbSubFunctions.addListener( CustomChooserComposite.DROPDOWN_EVENT,
			new Listener( ) {

				public void handleEvent( Event event )
				{
					cmbSubFunctions.deselectAll( );

					ScriptParser parser = new ScriptParser( getEditorText( ) );

					Collection<IScriptMethodInfo> coll = parser.getAllMethodInfo( );

					for ( Iterator<IScriptMethodInfo> itr = coll.iterator( ); itr.hasNext( ); )
					{
						IScriptMethodInfo mtd = itr.next( );

						cmbSubFunctions.markSelection( METHOD_DISPLAY_INDENT
								+ mtd.getName( ) );
					}
				}

			} );

	cmbSubFunctionsViewer = new TextComboViewer( cmbSubFunctions );
	cmbSubFunctionsViewer.setContentProvider( subProvider );
	cmbSubFunctionsViewer.setLabelProvider( subProvider );
	cmbSubFunctionsViewer.addSelectionChangedListener( subProvider );
	cmbSubFunctionsViewer.addSelectionChangedListener( propertyDefnChangeListener );

	// Initialize the model for the document.
	Object model = getModel( );
	if ( model != null )
	{
		cmbExpList.setVisible( true );
		cmbSubFunctions.setVisible( true );
		setComboViewerInput( model );
	}
	else
	{
		setComboViewerInput( Messages.getString( "JSEditor.Input.trial" ) ); //$NON-NLS-1$
	}
	cmbExprListViewer.addSelectionChangedListener( palettePage.getSupport( ) );
	cmbExprListViewer.addSelectionChangedListener( propertyDefnChangeListener );

	scriptEditor.createPartControl( child );
	scriptValidator = new ScriptValidator( getViewer( ) );

	disableEditor( );

	SourceViewer viewer = getViewer( );
	IDocument document = viewer == null ? null : viewer.getDocument( );

	if ( document != null )
	{
		IDocumentUndoManager undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager( document );

		if ( undoManager != null )
		{
			undoManager.addDocumentUndoListener( undoListener );
		}
		document.addDocumentListener( documentListener );
	}
}
 
开发者ID:eclipse,项目名称:birt,代码行数:80,代码来源:JSEditor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VolumeProviderCompat类代码示例发布时间:2022-05-22
下一篇:
Java ClientHttpRequestFactorySelector类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap