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


Java CompoundEdit.end方法代码示例

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


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

示例1: 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);
}
 
开发者ID:phon-ca,项目名称:phon,代码行数:25,代码来源:ResetAlignmentCommand.java

示例2: 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);
}
 
开发者ID:phon-ca,项目名称:phon,代码行数:26,代码来源:ResetSyllabificationCommand.java

示例3: 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);
}
 
开发者ID:phon-ca,项目名称:phon,代码行数:22,代码来源:DeleteParticipantAction.java

示例4: 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);
}
 
开发者ID:phon-ca,项目名称:phon,代码行数:22,代码来源:ValidateTierAction.java

示例5: testAllowCompoundEdit

import javax.swing.undo.CompoundEdit; //导入方法依赖的package包/类
public void testAllowCompoundEdit()
{
	UndoableEdit stubEdit1 = new AbstractUndoableEdit(); 
	UndoableEdit stubEdit2 = new AbstractUndoableEdit(); 
	UndoableEdit stubEdit3 = new AbstractUndoableEdit(); 
	CompoundEdit ce = new CompoundEdit();
	ce.addEdit(stubEdit1);
	ce.addEdit(stubEdit2);
	ce.addEdit(stubEdit3);
	ce.end();
	undoManager.addEdit(ce);
	assertTrue(undoManager.canUndo());
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:14,代码来源:TestUndoManager.java

示例6: propertyChanged

import javax.swing.undo.CompoundEdit; //导入方法依赖的package包/类
@Override
public void propertyChanged(PropertyChangeEvent evt) {
       hasChanged = true;
       logger.debug("Watcher: " + this + ", Property: " + evt.getPropertyName() + " from " + evt.getSource().toString() + " has changed.");
       logger.debug("old value: " + evt.getOldValue() + ", new value: " + evt.getNewValue());
       if (((SPObject)evt.getSource()).isMagicEnabled()) {
		UndoableEdit ue = new MMOPropertyChangeUndoableEdit(evt);
		
       	if ("UNDOSTATE".equals(evt.getPropertyName())) {
           	boolean undoing = (Boolean) evt.getNewValue();
           	if (undoing) {
           		logger.debug("Starting new compound edit with undoCount: " + undoCount);
           		undoCount++;
           		if (undoCount == 1) {
           			ce = new CompoundEdit();
           		}
           	} else {
           		logger.debug("Ending compound edit with undoCount: " + undoCount);
           		undoCount--;
           		if (undoCount == 0) {
           			ce.end();
           			undo.addEdit(ce);
               		ce = null;
           		}
           	}
           } else if (undoCount > 0) {
       		ce.addEdit(ue);
       	} else {
       		undo.addEdit(ue);
       	}
	} else {
		if (!undo.canUndo()) {
			hasChanged = false;
		}
		pane.undoEventFired(evt);
	}
       swingSession.refreshUndoAction();
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:39,代码来源:MMOChangeUndoWatcher.java

示例7: actionPerformed

import javax.swing.undo.CompoundEdit; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
	final Record r = getRecord();
	if(r.numberOfGroups() > 1) {
		// confirm
		final MessageDialogProperties props = new MessageDialogProperties();
		props.setRunAsync(false);
		props.setTitle("Merge All Groups");
		props.setHeader("Merge all groups");
		props.setMessage("Merge all groups for current record?");
		props.setOptions(MessageDialogProperties.okCancelOptions);
		final int retVal = NativeDialogs.showMessageDialog(props);
		if(retVal != 0) return;
		
		final CompoundEdit cmpEdit = new CompoundEdit(){

			@Override
			public String getUndoPresentationName() {
				return "Undo merge all groups";
			}

			@Override
			public String getRedoPresentationName() {
				return "Redo merge all groups";
			}
			
		};
		while(r.numberOfGroups() > 1) {
			final MergeGroupEdit edit = new MergeGroupEdit(getEditorView().getEditor(), r, 0);
			edit.doIt();
			cmpEdit.addEdit(edit);
		}
		cmpEdit.end();
		
		getEditorView().getEditor().getUndoSupport().postEdit(cmpEdit);
	}
}
 
开发者ID:phon-ca,项目名称:phon,代码行数:38,代码来源:MergeAllGroupsCommand.java

示例8: actionPerformed

import javax.swing.undo.CompoundEdit; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    int[] sel = table.getSelectedRows();
    if (sel.length > 0) {

        // Make sure no cell is being edited, as caused by the
        // keystroke. This makes the content hang on the screen.
        assureNotEditing();

        String msg = (sel.length > 1 ? Localization.lang("Really delete the %0 selected entries?",
                Integer.toString(sel.length)) : Localization.lang("Really delete the selected entry?"));
        int answer = JOptionPane.showConfirmDialog(parent, msg, Localization.lang("Delete strings"),
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (answer == JOptionPane.YES_OPTION) {
            CompoundEdit ce = new CompoundEdit();
            for (int i = sel.length - 1; i >= 0; i--) {
                // Delete the strings backwards to avoid moving indexes.

                BibtexString subject = strings.get(sel[i]);

                // Store undo information:
                ce.addEdit(new UndoableRemoveString(panel, base, subject));

                base.removeString(subject.getId());
            }
            ce.end();
            panel.getUndoManager().addEdit(ce);

            refreshTable();
            if (!base.hasNoStrings()) {
                table.setRowSelectionInterval(0, 0);
            }
        }
    }
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:36,代码来源:StringDialog.java

示例9: endCompoundEdit

import javax.swing.undo.CompoundEdit; //导入方法依赖的package包/类
public void endCompoundEdit() {
	CompoundEdit edit = compoundEdits.pop();
	edit.end();
	addEdit(edit);
}
 
开发者ID:mgropp,项目名称:pdfjumbler,代码行数:6,代码来源:UndoableList.java

示例10: testDeleteEachTenthCharFromDocument

import javax.swing.undo.CompoundEdit; //导入方法依赖的package包/类
public void testDeleteEachTenthCharFromDocument() throws Exception {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < 20; i++) {
        for (int j = 0; j < 10; j++) {
            sb.append((char)('0' + j));
        }
    }
    
    content = sb.toString();
    
    StyledDocument doc = support.openDocument();
    assertEquals("200 chars there", 200, doc.getLength());
    
    CompoundEdit bigEdit = new CompoundEdit();
    support.getUndoRedo().undoableEditHappened(new UndoableEditEvent(doc, bigEdit));
    
    assertTrue("Big edit will consume other edits", bigEdit.isInProgress());
    
    for (int i = 199; i >= 0; i -= 10) {
        doc.remove(i, 1);
    }
    
    assertTrue("Big edit was still in consume mode", bigEdit.isInProgress());
    bigEdit.end();
    assertFalse("Big edit is over", bigEdit.isInProgress());
    assertTrue("Document is modified", modified);
    assertTrue("We can undo", support.getUndoRedo().canUndo());
    
    if (doc.getText(0, doc.getLength()).indexOf('9') != -1) {
        fail("There should be no 9 in the doc:\n" + doc.getText(0, doc.getLength()));
    }
    
    support.getUndoRedo().undo();
    
    assertEquals("Again 200", 200, doc.getLength());
    assertFalse("Not modified anymore", modified);

    
    assertTrue("We can redo", support.getUndoRedo().canRedo());
    support.getUndoRedo().redo();
    
    assertTrue("Document is modified", modified);
    assertTrue("We can undo", support.getUndoRedo().canUndo());
    
    if (doc.getText(0, doc.getLength()).indexOf('9') != -1) {
        fail("There should be no 9 in the doc:\n" + doc.getText(0, doc.getLength()));
    }
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:50,代码来源:UndoRedoWrappingExampleTest.java

示例11: testDeleteEachTenthCharOnModifiedDocument

import javax.swing.undo.CompoundEdit; //导入方法依赖的package包/类
public void testDeleteEachTenthCharOnModifiedDocument() throws Exception {
    
    StyledDocument doc = support.openDocument();
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < 20; i++) {
        for (int j = 0; j < 10; j++) {
            sb.append((char)('0' + j));
        }
    }
    assertEquals("empty", 0, doc.getLength());
    doc.insertString(0, sb.toString(), null);
    assertEquals("200 chars there", 200, doc.getLength());
    
    CompoundEdit bigEdit = new CompoundEdit();
    support.getUndoRedo().undoableEditHappened(new UndoableEditEvent(doc, bigEdit));
    
    assertTrue("Big edit will consume other edits", bigEdit.isInProgress());
    
    for (int i = 199; i >= 0; i -= 10) {
        doc.remove(i, 1);
    }
    
    assertTrue("Big edit was still in consume mode", bigEdit.isInProgress());
    bigEdit.end();
    assertFalse("Big edit is over", bigEdit.isInProgress());
    assertTrue("Document is modified", modified);
    assertTrue("We can undo", support.getUndoRedo().canUndo());
    
    if (doc.getText(0, doc.getLength()).indexOf('9') != -1) {
        fail("There should be no 9 in the doc:\n" + doc.getText(0, doc.getLength()));
    }
    
    support.getUndoRedo().undo();
    
    assertEquals("Again 200", 200, doc.getLength());
    assertTrue("Still modified", modified);

    
    assertTrue("We can redo", support.getUndoRedo().canRedo());
    support.getUndoRedo().redo();
    
    assertTrue("Document is modified", modified);
    assertTrue("We can undo", support.getUndoRedo().canUndo());
    
    if (doc.getText(0, doc.getLength()).indexOf('9') != -1) {
        fail("There should be no 9 in the doc:\n" + doc.getText(0, doc.getLength()));
    }
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:50,代码来源:UndoRedoWrappingExampleTest.java

示例12: delete

import javax.swing.undo.CompoundEdit; //导入方法依赖的package包/类
protected void delete() {
    CompoundEdit deletes = new CompoundEdit();

    for (GraphNode selNode : selectedNodes) {
        if (!selNode.isStartNode() && !selNode.isEndNode()) {
            //sterg nodul
            for (GraphNode graphNode : currentGraph.getGraphNodes().values()) {//sterg toate pathurile spre el

                if (!graphNode.getChildNodesIndexes().contains(selNode.getIndex())) continue;

                DeletePathCommand deletePathCommand = new DeletePathCommand();
                deletePathCommand.start = graphNode;
                deletePathCommand.end = selNode;
                deletePathCommand.priorityIndex = graphNode.getChildNodesIndexes().indexOf(selNode.getIndex());

                graphNode.getChildNodesIndexes().remove(deletePathCommand.priorityIndex);
                deletes.addEdit(deletePathCommand);
            }

            for (String clause : renderingInfos.get(selNode).matchingClauses)
                if (clause.startsWith(":")) {
                    GrammarEditor.theEditor.mustRefreshGraphsTree = true;
                    break;
                }

            selNode.getParentGraph().getGraphNodes().remove(selNode.getIndex());

            DeleteNodeCommand deleteCommand = new DeleteNodeCommand();
            deleteCommand.gn = selNode;
            deletes.addEdit(deleteCommand);
        } else {
            Toolkit.getDefaultToolkit().beep();
        }
    }

    SelectNodesCommand selectCommand = new SelectNodesCommand();
    selectCommand.editor = this;
    selectCommand.curentSelection = selectedNodes;
    selectCommand.prevSelection = new ArrayList<GraphNode>(selectedNodes);
    selectedNodes.clear();
    selectCommand.nextSelection = new ArrayList<GraphNode>();
    deletes.addEdit(selectCommand);

    deletes.end();
    undoSupport.postEdit(deletes);

    updateUI();
}
 
开发者ID:radsimu,项目名称:UaicNlpToolkit,代码行数:49,代码来源:GrammarEditorComponent.java

示例13: insertNode

import javax.swing.undo.CompoundEdit; //导入方法依赖的package包/类
protected GraphNode insertNode(int x, int y) {

        CompoundEdit compCommand = new CompoundEdit();

        InsertNodeCommand insertCommand = new InsertNodeCommand();
        GraphNode newGraphNode = new GraphNode(currentGraph.grammar);
        newGraphNode.setTokenMatchingCode("<<E>>");
        x = x - 9;
        boolean ok;
        do {
            ok = true;
            for (GraphNode node : currentGraph.getGraphNodes().values()) {
                if (node.getX() == x && node.getY() == y) {
                    x = x - 10;
                    y = y - 10;
                    ok = false;
                }
            }
        } while (!ok);

        newGraphNode.setX(x);
        newGraphNode.setY(y);
        newGraphNode.setParentGraph(currentGraph);
        renderingInfos.put(newGraphNode, new GraphNodeRenderingInfo(newGraphNode));
        insertCommand.gn = newGraphNode;
        insertCommand.renderingInfos = renderingInfos;
        compCommand.addEdit(insertCommand);

        SelectNodesCommand selectCommand = new SelectNodesCommand();
        selectCommand.editor = this;
        selectCommand.prevSelection = new ArrayList<GraphNode>(selectedNodes);
        selectCommand.curentSelection = selectedNodes;
        selectedNodes.clear();
        selectedNodes.add(newGraphNode);
        selectCommand.nextSelection = new ArrayList<GraphNode>(selectedNodes);
        compCommand.addEdit(selectCommand);

        compCommand.end();
        undoSupport.postEdit(compCommand);
        return newGraphNode;
    }
 
开发者ID:radsimu,项目名称:UaicNlpToolkit,代码行数:42,代码来源:GrammarEditorComponent.java

示例14: replace

import javax.swing.undo.CompoundEdit; //导入方法依赖的package包/类
public void replace() {
	final FindManager findManager = getFindManager();
	
	if(findManager.getMatchedExpr() != null && findManager.getMatchedRange() != null) {
		final Tier<String> replaceTier = searchTiers.get(REPLACE_TIER_NAME);
		if(replaceTier != null && replaceTier.numberOfGroups() > 0) {
			final String replaceExpr = replaceTier.getGroup(0);
			final Object newVal = findManager.getMatchedExpr().replace(replaceExpr);
			
			// re-syllabify if an IPA tier
			final SessionRange sr = findManager.getMatchedRange();
			
			final Record record = getEditor().getSession().getRecord(sr.getRecordIndex());
			
			@SuppressWarnings({ "unchecked", "rawtypes" })
			final TierEdit<?> tierEdit = new TierEdit(getEditor(), 
					getEditor().currentRecord().getTier(sr.getRecordRange().getTier()),
					sr.getRecordRange().getGroupRange().getGroupIndex(), newVal);
			
			if(newVal instanceof IPATranscript) {
				final IPATranscript ipa = (IPATranscript)newVal;
				final Syllabifier syllabifier = getSyllabifier(sr.getRecordRange().getTier());
				if(syllabifier != null) {
					syllabifier.syllabify(ipa.toList());
				}
				
				// update alignment
				
				final CompoundEdit edit = new CompoundEdit();
				final PhoneMap pm = (new PhoneAligner()).calculatePhoneMap(
						record.getIPATarget().getGroup(sr.getRecordRange().getGroupRange().getGroupIndex()),
						record.getIPAActual().getGroup(sr.getRecordRange().getGroupRange().getGroupIndex()));
				final TierEdit<PhoneMap> alignmentEdit = 
						new TierEdit<PhoneMap>(getEditor(), record.getPhoneAlignment(), 
								sr.getRecordRange().getGroupRange().getGroupIndex(), pm);
				tierEdit.doIt();
				edit.addEdit(tierEdit);
				alignmentEdit.doIt();
				edit.addEdit(alignmentEdit);
				edit.end();
				getEditor().getUndoSupport().postEdit(edit);
			} else {
				getEditor().getUndoSupport().postEdit(tierEdit);
			}
			
			getEditor().getSelectionModel().clear();
			
			
		}
	}
}
 
开发者ID:phon-ca,项目名称:phon,代码行数:52,代码来源:FindAndReplaceEditorView.java

示例15: replaceAll

import javax.swing.undo.CompoundEdit; //导入方法依赖的package包/类
public void replaceAll() {
	final Tier<String> replaceTier = searchTiers.get(REPLACE_TIER_NAME);
	final String replaceExpr = replaceTier.getGroup(0);

	// create a new find manager
	final Session session = getEditor().getSession();
	final FindManager findManager = new FindManager(session);
	findManager.setAnyExpr(getAnyTierExpr());
	findManager.setSearchTier(getSearchTiers());
	for(String searchTier:findManager.getSearchTiers()) {
		findManager.setExprForTier(searchTier, exprForTier(searchTier));
	}
	findManager.setDirection(FindDirection.FORWARDS);
	final SessionLocation startLoc = 
			new SessionLocation(0, new RecordLocation(findManager.getSearchTiers()[0],
					new GroupLocation(0, 0)));
	findManager.setCurrentLocation(startLoc);
	
	
	final CompoundEdit edit = new CompoundEdit();
	int occurrences = 0;
	
	SessionRange currentRange = null;
	while((currentRange = findManager.findNext()) != null) {
		++occurrences;
		
		final Record r = session.getRecord(currentRange.getRecordIndex());
		final Tier<?> tier = r.getTier(currentRange.getRecordRange().getTier());
		
		final Object newVal = findManager.getMatchedExpr().replace(replaceExpr);
		
		// re-syllabify if an IPA tier
		@SuppressWarnings({ "unchecked", "rawtypes" })
		final TierEdit<?> tierEdit = new TierEdit(getEditor(), tier,
				currentRange.getRecordRange().getGroupRange().getGroupIndex(), newVal);
		tierEdit.doIt();
		edit.addEdit(tierEdit);
		
		if(newVal instanceof IPATranscript) {
			final IPATranscript ipa = (IPATranscript)newVal;
			final Syllabifier syllabifier = getSyllabifier(currentRange.getRecordRange().getTier());
			if(syllabifier != null) {
				syllabifier.syllabify(ipa.toList());
			}
			
			// update alignment
			
			final PhoneMap pm = (new PhoneAligner()).calculatePhoneMap(
					r.getIPATarget().getGroup(currentRange.getRecordRange().getGroupRange().getGroupIndex()),
					r.getIPAActual().getGroup(currentRange.getRecordRange().getGroupRange().getGroupIndex()));
			final TierEdit<PhoneMap> alignmentEdit = 
					new TierEdit<PhoneMap>(getEditor(), r.getPhoneAlignment(), 
							currentRange.getRecordRange().getGroupRange().getGroupIndex(), pm);
			alignmentEdit.doIt();

			edit.addEdit(alignmentEdit);
			edit.end();
		}
	}
	edit.end();
	
	if(occurrences > 0) {
		final EditorEvent ee = new EditorEvent(EditorEventType.MODIFICATION_EVENT, this);
		getEditor().getEventManager().queueEvent(ee);
		final EditorEvent refresh = new EditorEvent(EditorEventType.RECORD_REFRESH_EVT, this);
		getEditor().getEventManager().queueEvent(refresh);
		
		getEditor().getUndoSupport().postEdit(edit);
	}
	
	final String message = 
			"Replaced " + occurrences + " occurrences with " + replaceExpr;
	final Toast toast = ToastFactory.makeToast(message);
	toast.start(replaceAllBtn);
}
 
开发者ID:phon-ca,项目名称:phon,代码行数:76,代码来源:FindAndReplaceEditorView.java


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