本文整理汇总了Java中javax.swing.undo.CompoundEdit类的典型用法代码示例。如果您正苦于以下问题:Java CompoundEdit类的具体用法?Java CompoundEdit怎么用?Java CompoundEdit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompoundEdit类属于javax.swing.undo包,在下文中一共展示了CompoundEdit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTrivialChunk
import javax.swing.undo.CompoundEdit; //导入依赖的package包/类
public void testTrivialChunk() throws Exception {
content = "";
StyledDocument d = support.openDocument();
// same operations as testSingleChunk,
// but don't test modified/canUndo/canRedo state
CompoundEdit ce = beginChunk(d);
d.insertString(d.getLength(), "a", null);
d.insertString(d.getLength(), "b", null);
endChunk(d, ce);
assertEquals("data", "ab", d.getText(0, d.getLength()));
ur().undo();
assertEquals("after undo data", "", d.getText(0, d.getLength()));
ur().redo();
assertEquals("after redo data", "ab", d.getText(0, d.getLength()));
}
示例2: hookableActionPerformed
import javax.swing.undo.CompoundEdit; //导入依赖的package包/类
@Override
public void hookableActionPerformed(ActionEvent e) {
final Record r = getEditor().currentRecord();
final Tier<PhoneMap> alignmentTier = r.getPhoneAlignment();
final CompoundEdit edit = new CompoundEdit();
final PhoneAligner aligner = new PhoneAligner();
for(int i = 0; i < r.numberOfGroups(); i++) {
final Group group = r.getGroup(i);
final PhoneMap newPm = aligner.calculatePhoneMap(group.getIPATarget(), group.getIPAActual());
final TierEdit<PhoneMap> ed = new TierEdit<PhoneMap>(getEditor(), alignmentTier, i, newPm);
ed.doIt();
edit.addEdit(ed);
}
final EditorEvent ee = new EditorEvent(EditorEventType.TIER_CHANGED_EVT, getView(), SystemTierType.SyllableAlignment.getName());
getEditor().getEventManager().queueEvent(ee);
edit.end();
getEditor().getUndoSupport().postEdit(edit);
}
示例3: hookableActionPerformed
import javax.swing.undo.CompoundEdit; //导入依赖的package包/类
@Override
public void hookableActionPerformed(ActionEvent e) {
final SyllabifierInfo info = getEditor().getSession().getExtension(SyllabifierInfo.class);
final Record r = getEditor().currentRecord();
final Tier<IPATranscript> tier =
r.getTier(ipaTier, IPATranscript.class);
if(tier == null) return;
final SyllabifierLibrary library = SyllabifierLibrary.getInstance();
Language syllabifierLanguage = info.getSyllabifierLanguageForTier(tier.getName());
if(syllabifierLanguage == null)
syllabifierLanguage = library.defaultSyllabifierLanguage();
final Syllabifier syllabifier = library.getSyllabifierForLanguage(syllabifierLanguage);
final CompoundEdit edit = new CompoundEdit();
for(int i = 0; i < tier.numberOfGroups(); i++) {
final SyllabifyEdit ed = new SyllabifyEdit(getEditor(), tier, i, syllabifier);
ed.doIt();
edit.addEdit(ed);
}
edit.end();
getEditor().getUndoSupport().postEdit(edit);
}
示例4: hookableActionPerformed
import javax.swing.undo.CompoundEdit; //导入依赖的package包/类
@Override
public void hookableActionPerformed(ActionEvent e) {
final SessionEditor editor = getEditor();
final Session session = editor.getSession();
final CompoundEdit edit = new CompoundEdit();
final RemoveParticipantEdit removePartEdit = new RemoveParticipantEdit(editor, participant);
removePartEdit.doIt();
edit.addEdit(removePartEdit);
for(Record r:session.getRecords()) {
if(r.getSpeaker() == participant) {
final ChangeSpeakerEdit chSpeakerEdit = new ChangeSpeakerEdit(editor, r, null);
chSpeakerEdit.doIt();
edit.addEdit(chSpeakerEdit);
}
}
edit.end();
editor.getUndoSupport().postEdit(edit);
}
示例5: hookableActionPerformed
import javax.swing.undo.CompoundEdit; //导入依赖的package包/类
@Override
public void hookableActionPerformed(ActionEvent e) {
final CompoundEdit edit = new CompoundEdit();
for(int i = 0; i < tier.numberOfGroups(); i++) {
final IPATranscript grp = tier.getGroup(i);
final AlternativeTranscript alts = grp.getExtension(AlternativeTranscript.class);
if(alts != null && alts.get(transcriber.getUsername()) != null) {
final IPATranscript ipa = alts.get(transcriber.getUsername());
alts.setSelected(transcriber.getUsername());
ipa.putExtension(AlternativeTranscript.class, alts);
final TierEdit<IPATranscript> tierEdit = new TierEdit<IPATranscript>(getEditor(), tier, i, ipa);
tierEdit.doIt();
edit.addEdit(tierEdit);
}
}
edit.end();
getEditor().getUndoSupport().postEdit(edit);
}
示例6: unabbreviate
import javax.swing.undo.CompoundEdit; //导入依赖的package包/类
/**
* Unabbreviate the journal name of the given entry.
*
* @param entry The entry to be treated.
* @param fieldName The field name (e.g. "journal")
* @param ce If the entry is changed, add an edit to this compound.
* @return true if the entry was changed, false otherwise.
*/
public boolean unabbreviate(BibDatabase database, BibEntry entry, String fieldName, CompoundEdit ce) {
if (!entry.hasField(fieldName)) {
return false;
}
String text = entry.getField(fieldName).get();
String origText = text;
if (database != null) {
text = database.resolveForStrings(text);
}
if (!journalAbbreviationRepository.isKnownName(text)) {
return false; // cannot do anything if it is not known
}
if (!journalAbbreviationRepository.isAbbreviatedName(text)) {
return false; // cannot unabbreviate unabbreviated name.
}
Abbreviation abbreviation = journalAbbreviationRepository.getAbbreviation(text).get(); // must be here
String newText = abbreviation.getName();
entry.setField(fieldName, newText);
ce.addEdit(new UndoableFieldChange(entry, fieldName, origText, newText));
return true;
}
示例7: abbreviate
import javax.swing.undo.CompoundEdit; //导入依赖的package包/类
/**
* Abbreviate the journal name of the given entry.
*
* @param database The database the entry belongs to, or null if no database.
* @param entry The entry to be treated.
* @param fieldName The field name (e.g. "journal")
* @param ce If the entry is changed, add an edit to this compound.
* @return true if the entry was changed, false otherwise.
*/
public boolean abbreviate(BibDatabase database, BibEntry entry, String fieldName, CompoundEdit ce) {
if (!entry.hasField(fieldName)) {
return false;
}
String text = entry.getField(fieldName).get();
String origText = text;
if (database != null) {
text = database.resolveForStrings(text);
}
if (!journalAbbreviationRepository.isKnownName(text)) {
return false; // unknown, cannot un/abbreviate anything
}
String newText = getAbbreviatedName(journalAbbreviationRepository.getAbbreviation(text).get());
if (newText.equals(origText)) {
return false;
}
entry.setField(fieldName, newText);
ce.addEdit(new UndoableFieldChange(entry, fieldName, origText, newText));
return true;
}
示例8: addGroups
import javax.swing.undo.CompoundEdit; //导入依赖的package包/类
/**
* Adds the specified node as a child of the current root. The group contained in <b>newGroups </b> must not be of
* type AllEntriesGroup, since every tree has exactly one AllEntriesGroup (its root). The <b>newGroups </b> are
* inserted directly, i.e. they are not deepCopy()'d.
*/
private static void addGroups(GroupTreeNode newGroups, CompoundEdit ce) {
// paranoia: ensure that there are never two instances of AllEntriesGroup
if (newGroups.getGroup() instanceof AllEntriesGroup) {
return; // this should be impossible anyway
}
Globals.stateManager.getActiveDatabase()
.map(BibDatabaseContext::getMetaData)
.flatMap(MetaData::getGroups)
.ifPresent(newGroups::moveTo);
//UndoableAddOrRemoveGroup undo = new UndoableAddOrRemoveGroup(groupsRoot,
// new GroupTreeNodeViewModel(newGroups), UndoableAddOrRemoveGroup.ADD_NODE);
//ce.addEdit(undo);
}
示例9: beginCompoundEdit
import javax.swing.undo.CompoundEdit; //导入依赖的package包/类
public void beginCompoundEdit(final String name) {
CompoundEdit edit = new CompoundEdit() {
private static final long serialVersionUID = 2894975385303438798L;
@Override
public String getPresentationName() {
return name;
}
};
compoundEdits.push(edit);
}
示例10: UndoableEditDelegate
import javax.swing.undo.CompoundEdit; //导入依赖的package包/类
private UndoableEditDelegate(UndoableEdit ed, DataObject dob, RefactoringSession session) {
undoManager = UndoManager.getDefault();
ces = dob.getLookup().lookup(CloneableEditorSupport.class);
//this.delegate = ed;
this.inner = new CompoundEdit();
inner.addEdit(ed);
delegate = ed;
this.session = session;
}
示例11: testSingleChunk
import javax.swing.undo.CompoundEdit; //导入依赖的package包/类
public void testSingleChunk() throws Exception {
content = "";
StyledDocument d = support.openDocument();
assertFalse("initially: not modified", support.isModified());
assertFalse("initially: no undo", ur().canUndo());
assertFalse("initially: no redo", ur().canRedo());
CompoundEdit ce = beginChunk(d);
assertFalse("start chunk: not modified", support.isModified());
assertFalse("start chunk: no undo", ur().canUndo());
assertFalse("start chunk: no redo", ur().canRedo());
d.insertString(d.getLength(), "a", null);
assertTrue("insert: modified", support.isModified());
assertTrue("insert: can undo", ur().canUndo());
assertFalse("insert: no redo", ur().canRedo());
d.insertString(d.getLength(), "b", null);
endChunk(d, ce);
assertEquals("chunk: data", "ab", d.getText(0, d.getLength()));
assertTrue("endChunk: modified", support.isModified());
assertTrue("endChunk: can undo", ur().canUndo());
assertFalse("endChunk: no redo", ur().canRedo());
ur().undo();
assertEquals("after undo: data", "", d.getText(0, d.getLength()));
assertFalse("undo: not modified", support.isModified());
assertFalse("undo: no undo", ur().canUndo());
assertTrue("undo: can redo", ur().canRedo());
ur().redo();
assertEquals("after redo: data", "ab", d.getText(0, d.getLength()));
assertTrue("redo: modified", support.isModified());
assertTrue("redo: can undo", ur().canUndo());
assertFalse("redo: no redo", ur().canRedo());
}
示例12: testNestedChunks
import javax.swing.undo.CompoundEdit; //导入依赖的package包/类
public void testNestedChunks() throws Exception {
content = "";
StyledDocument d = support.openDocument();
CompoundEdit ce1 = beginChunk(d);
d.insertString(d.getLength(), "a", null);
d.insertString(d.getLength(), "b", null);
CompoundEdit ce2 = beginChunk(d); // creates a separate undoable chunk
d.insertString(d.getLength(), "c", null);
d.insertString(d.getLength(), "d", null);
endChunk(d, ce1);
d.insertString(d.getLength(), "e", null);
d.insertString(d.getLength(), "f", null);
endChunk(d, ce2);
assertEquals("data", "abcdef", d.getText(0, d.getLength()));
// following fails if nesting not supported
ur().undo();
assertEquals("undo1", "abcd", d.getText(0, d.getLength()));
ur().undo();
assertEquals("undo2", "ab", d.getText(0, d.getLength()));
ur().undo();
assertEquals("undo3", "", d.getText(0, d.getLength()));
}
示例13: UndoableEditDelegate
import javax.swing.undo.CompoundEdit; //导入依赖的package包/类
private UndoableEditDelegate(UndoableEdit ed, BaseDocument doc, InstantRefactoringPerformer performer) {
DataObject dob = (DataObject) doc.getProperty(BaseDocument.StreamDescriptionProperty);
this.ces = dob.getLookup().lookup(CloneableEditorSupport.class);
this.inner = new CompoundEdit();
this.inner.addEdit(ed);
this.delegate = ed;
this.performer = performer;
}
示例14: fillIn
import javax.swing.undo.CompoundEdit; //导入依赖的package包/类
/**
* This is called as part of {@link #syncSill} to add needed panels undoably.
*/
private void fillIn(final int loop, final Sill sill, final CompoundEdit compoundEdit)
{
if (loop>sill.size()-1)
{
Sill addition = new Sill();
addition.setName(AbstractNamed.NAMES_TEXT.getString("panelLabel")+" "+(loop+1));
MysteryAddEdit createEdit = new MysteryAddEdit(sill, addition);
createEdit.execute();
compoundEdit.addEdit(createEdit);
}
}
示例15: trimFat
import javax.swing.undo.CompoundEdit; //导入依赖的package包/类
/**
* This is called as part of {@link #syncSill} to remove unneeded panels undoably.
*/
private void trimFat(final Sill sill, final CompoundEdit compoundEdit)
{
if (sill.size()>=apertureQuantity) // TODO move this outside optimization loop
{
TrimExcessItemsEdit trimEdit = new TrimExcessItemsEdit(sill, apertureQuantity);
trimEdit.execute();
compoundEdit.addEdit(trimEdit);
}
}