Java Code Examples for javax.swing.undo.UndoManager#undo()

The following examples show how to use javax.swing.undo.UndoManager#undo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SyncTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testCreateGlobalElementUndoRedo() throws Exception {
    SchemaModel model = Util.loadSchemaModel("resources/Empty.xsd");
    UndoManager ur = new UndoManager();
    model.addUndoableEditListener(ur);
    SchemaComponentFactory fact = model.getFactory();
    GlobalElement ge = fact.createGlobalElement();
    
    model.startTransaction();
    model.getSchema().addElement(ge);
    ge.setName("Foo"); // edit #1
    LocalComplexType lct = fact.createLocalComplexType();
    Sequence seq = fact.createSequence();
    lct.setDefinition(seq); 
    ge.setInlineType(lct);
    model.endTransaction();
    
    assertEquals(1, model.getSchema().getElements().size());
    ur.undo();
    assertEquals(0, model.getSchema().getElements().size());

    ur.redo();
    ge = model.getSchema().getElements().iterator().next();
    assertEquals("Foo", ge.getName());
    assertNotNull(ge.getInlineType());
    assertNotNull(((LocalComplexType)ge.getInlineType()).getDefinition());
}
 
Example 2
Source File: AbstractModelTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testSyncUndoRedo() throws Exception {
    defaultSetup();
    UndoManager urListener = new UndoManager();
    mModel.addUndoableEditListener(urListener);
    assertEquals("setup: initial", 1, mModel.getRootComponent().getChildren(C.class).size());
    
    Util.setDocumentContentTo(mDoc, "resources/test2.xml");
    mModel.sync();
    assertEquals("setup: sync", 0, mModel.getRootComponent().getChildren(C.class).size());

    urListener.undo();
    assertEquals("undo sync", 1, mModel.getRootComponent().getChildren(C.class).size());

    urListener.redo();
    assertEquals("undo sync", 0, mModel.getRootComponent().getChildren(C.class).size());
}
 
Example 3
Source File: PlainDocumentTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testBehaviour() throws Exception {
    Document doc = new PlainDocument();
    doc.insertString(0, "test hello world", null);
    UndoManager undo = new UndoManager();
    doc.addUndoableEditListener(undo);
    Position pos = doc.createPosition(2);
    doc.remove(0, 3);
    assert (pos.getOffset() == 0);
    undo.undo();
    assert (pos.getOffset() == 2);
    
    Position pos2 = doc.createPosition(5);
    doc.remove(4, 2);
    Position pos3 = doc.createPosition(4);
    assertSame(pos2, pos3);
    undo.undo();
    assert (pos3.getOffset() == 5);
}
 
Example 4
Source File: AbstractModelTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testUndoRedoWithIdentity() throws Exception {
    mModel = Util.loadModel("resources/test1_name.xml");
    UndoManager ur = new UndoManager();
    mModel.addUndoableEditListener(ur);

    E e1 = mModel.getRootComponent().getChild(E.class);
    assertNull(e1.getValue());
    
    mModel.startTransaction();
    String v = "new test value";
    e1.setValue(v);
    mModel.endTransaction();
    assertEquals(v, e1.getValue());

    ur.undo();
    assertNull("expect null, get "+e1.getValue(), e1.getValue());
    
    ur.redo();
    assertEquals(v, e1.getValue());
}
 
Example 5
Source File: STSIssuedCertProfile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override()
public void displayConfig(WSDLComponent component, UndoManager undoManager) {
    UndoCounter undoCounter = new UndoCounter();
    WSDLModel model = component.getModel();
    
    model.addUndoableEditListener(undoCounter);

    JPanel profConfigPanel = new STSIssuedCert(component, this);
    DialogDescriptor dlgDesc = new DialogDescriptor(profConfigPanel, getDisplayName());
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);

    dlg.setVisible(true); 
    if (dlgDesc.getValue() == DialogDescriptor.CANCEL_OPTION) {
        for (int i=0; i<undoCounter.getCounter();i++) {
            if (undoManager.canUndo()) {
                undoManager.undo();
            }
        }
    }
    
    model.removeUndoableEditListener(undoCounter);
}
 
Example 6
Source File: SyncTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testSyncUndoRename() throws Exception {
    SchemaModel model = Util.loadSchemaModel(TEST_XSD);
    UndoManager um = new UndoManager();
    model.addUndoableEditListener(um);
    assertEquals(2, model.getSchema().getElements().size());
    
    Util.setDocumentContentTo(model, "resources/PurchaseOrder_SyncUndoRename.xsd");
    model.sync();
    assertEquals(2, model.getSchema().getElements().size());
    assertEquals("purchaseOrder2", model.getSchema().getElements().iterator().next().getName());

    um.undo();
    assertEquals(2, model.getSchema().getElements().size());
    assertEquals("purchaseOrder", model.getSchema().getElements().iterator().next().getName());

    um.redo();
    assertEquals(2, model.getSchema().getElements().size());
    assertEquals("purchaseOrder2", model.getSchema().getElements().iterator().next().getName());
}
 
Example 7
Source File: MutualCertificatesProfile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override()
public void displayConfig(WSDLComponent component, UndoManager undoManager) {
    UndoCounter undoCounter = new UndoCounter();
    WSDLModel model = component.getModel();
    
    model.addUndoableEditListener(undoCounter);

    JPanel profConfigPanel = new MutualCertificates(component, this);
    DialogDescriptor dlgDesc = new DialogDescriptor(profConfigPanel, getDisplayName());
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);

    dlg.setVisible(true); 
    if (dlgDesc.getValue() == DialogDescriptor.CANCEL_OPTION) {
        for (int i=0; i<undoCounter.getCounter();i++) {
            if (undoManager.canUndo()) {
                undoManager.undo();
            }
        }
    }
    
    model.removeUndoableEditListener(undoCounter);
}
 
Example 8
Source File: STSIssuedProfile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override()
public void displayConfig(WSDLComponent component, UndoManager undoManager) {
    UndoCounter undoCounter = new UndoCounter();
    WSDLModel model = component.getModel();
    
    model.addUndoableEditListener(undoCounter);

    JPanel profConfigPanel = new STSIssued(component, this);
    DialogDescriptor dlgDesc = new DialogDescriptor(profConfigPanel, getDisplayName());
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);

    dlg.setVisible(true); 
    if (dlgDesc.getValue() == DialogDescriptor.CANCEL_OPTION) {
        for (int i=0; i<undoCounter.getCounter();i++) {
            if (undoManager.canUndo()) {
                undoManager.undo();
            }
        }
    }
    
    model.removeUndoableEditListener(undoCounter);
}
 
Example 9
Source File: UsernameAuthPasswordDerivedKeysProfile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override()
public void displayConfig(WSDLComponent component, UndoManager undoManager) {
    UndoCounter undoCounter = new UndoCounter();
    WSDLModel model = component.getModel();
    
    model.addUndoableEditListener(undoCounter);

    JPanel profConfigPanel = new UsernameAuthPasswordDerivedKeys(component, this);
    DialogDescriptor dlgDesc = new DialogDescriptor(profConfigPanel, getDisplayName());
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);

    dlg.setVisible(true); 
    if (dlgDesc.getValue() == DialogDescriptor.CANCEL_OPTION) {
        for (int i=0; i<undoCounter.getCounter();i++) {
            if (undoManager.canUndo()) {
                undoManager.undo();
            }
        }
    }
    
    model.removeUndoableEditListener(undoCounter);
}
 
Example 10
Source File: SyncTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testSetAttributeOnGlobalComplexTypeUndoRedo() throws Exception {
    SchemaModel model = Util.loadSchemaModel("resources/PurchaseOrder.xsd");
    UndoManager ur = new UndoManager();
    model.addUndoableEditListener(ur);
    GlobalComplexType potype = model.getSchema().getComplexTypes().iterator().next();
    assertEquals("PurchaseOrderType", potype.getName());
    
    model.startTransaction();
    potype.setAbstract(Boolean.TRUE);
    model.endTransaction();
    
    ur.undo();
    assertNull(potype.getAttribute(SchemaAttributes.ABSTRACT));

    ur.redo();
    assertNotNull(potype.getAttribute(SchemaAttributes.ABSTRACT));
}
 
Example 11
Source File: STSIssuedSupportingTokenProfile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override()
public void displayConfig(WSDLComponent component, UndoManager undoManager) {
    UndoCounter undoCounter = new UndoCounter();
    WSDLModel model = component.getModel();
    
    model.addUndoableEditListener(undoCounter);

    JPanel profConfigPanel = new STSIssuedSupportingToken(component, this);
    DialogDescriptor dlgDesc = new DialogDescriptor(profConfigPanel, getDisplayName());
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);

    dlg.setVisible(true); 
    if (dlgDesc.getValue() == DialogDescriptor.CANCEL_OPTION) {
        for (int i=0; i<undoCounter.getCounter();i++) {
            if (undoManager.canUndo()) {
                undoManager.undo();
            }
        }
    }
    
    model.removeUndoableEditListener(undoCounter);
}
 
Example 12
Source File: KerberosProfile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override()
public void displayConfig(WSDLComponent component, UndoManager undoManager) {
    UndoCounter undoCounter = new UndoCounter();
    WSDLModel model = component.getModel();
    
    model.addUndoableEditListener(undoCounter);

    JPanel profConfigPanel = new Kerberos(component, this);
    DialogDescriptor dlgDesc = new DialogDescriptor(profConfigPanel, getDisplayName());
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);

    dlg.setVisible(true); 
    if (dlgDesc.getValue() == DialogDescriptor.CANCEL_OPTION) {
        for (int i=0; i<undoCounter.getCounter();i++) {
            if (undoManager.canUndo()) {
                undoManager.undo();
            }
        }
    }
    
    model.removeUndoableEditListener(undoCounter);
}
 
Example 13
Source File: SchemaTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testDeleteRollback() throws Exception {
    UndoManager um = new UndoManager();
    schema.getModel().addUndoableEditListener(um);
    
   GlobalElement stick = schema.getModel().getFactory().createGlobalElement();
   stick.setName("stickAfterRollbackElement");
   model.startTransaction();
   schema.addElement(stick);
   model.endTransaction();
   
   model.startTransaction();
   ArrayList<GlobalComplexType> types = new ArrayList(schema.getComplexTypes());
   ArrayList<GlobalElement> elements = new ArrayList(schema.getElements());
   GlobalElement element = elements.get(0);
   
     if(element.getName().equals("purchaseOrder")) {
        schema.removeElement(element);
                      
        String text = (( AbstractDocumentModel)model).getAccess().getCurrentDocumentText();
        assertTrue(text.indexOf("purchaseOrder")== -1);
        ( (AbstractModel)model).rollbackTransaction();
        text = (( AbstractDocumentModel)model).getAccess().getCurrentDocumentText();
        assertTrue(text.indexOf("purchaseOrder") > 0);
        assertTrue(text.indexOf("stickAfterRollbackElement") > 0);
   
        um.undo();
        text = (( AbstractDocumentModel)model).getAccess().getCurrentDocumentText();
        assertTrue(text.indexOf("stickAfterRollbackElement") == -1);

        um.redo();
        text = (( AbstractDocumentModel)model).getAccess().getCurrentDocumentText();
        assertTrue(text.indexOf("stickAfterRollbackElement") > 0);
       
     }
   
}
 
Example 14
Source File: SchemaTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testRollback() throws Exception {
    UndoManager um = new UndoManager();
    schema.getModel().addUndoableEditListener(um);
    
   GlobalElement stick = schema.getModel().getFactory().createGlobalElement();
   stick.setName("stickAfterRollbackElement");
   model.startTransaction();
   schema.addElement(stick);
   model.endTransaction();
   
   GlobalElement ge = schema.getModel().getFactory().createGlobalElement();
   ge.setName("newElement");
   int initialCount = schema.getElements().size();
   model.startTransaction();
   schema.addElement(ge);
   assertEquals(initialCount+1, schema.getElements().size());
   String text = (( AbstractDocumentModel)model).getAccess().getCurrentDocumentText();
   assertTrue(text.indexOf("newElement") > 0);
   ( (AbstractModel)model).rollbackTransaction();
   text = (( AbstractDocumentModel)model).getAccess().getCurrentDocumentText();
   assertTrue(text.indexOf("newElement") == -1);
   assertEquals(initialCount, schema.getElements().size());
   assertTrue(text.indexOf("stickAfterRollbackElement") > 0);
   
   um.undo();
   text = (( AbstractDocumentModel)model).getAccess().getCurrentDocumentText();
   assertTrue(text.indexOf("stickAfterRollbackElement") == -1);

   um.redo();
   text = (( AbstractDocumentModel)model).getAccess().getCurrentDocumentText();
   assertTrue(text.indexOf("stickAfterRollbackElement") > 0);
}
 
Example 15
Source File: AbstractModelTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testSyncRemoveAttribute() throws Exception {
    defaultSetup();
    UndoManager um = new UndoManager();
    mModel.addUndoableEditListener(um);
    
    A a1 = mModel.getRootComponent().getChild(TestComponent3.A.class);
    assertNull("setup", a1.getValue());
    
    mModel.startTransaction();
    String testValue = "edit #1: testRemoveAttribute";
    a1.setValue(testValue);
    mModel.endTransaction();
    assertEquals(testValue, a1.getValue());

    um.undo();
    assertNull("after undo expect no attribute 'value'", a1.getValue());
    
    um.redo();
    assertEquals(testValue, a1.getValue());

    Util.setDocumentContentTo(mDoc, "resources/test1.xml");
    mModel.sync();
    assertNull("sync back to original, expect no attribute 'value'", a1.getValue());
    plistener.assertEvent("value", testValue, null);
    listener.assertEvent(ComponentEvent.EventType.VALUE_CHANGED, a1);
    
    um.undo();
    mModel.getAccess().flush(); // after fix for 83963 need flush after undo/redo
    
    assertEquals(testValue, a1.getValue());
    mModel = Util.dumpAndReloadModel(mModel);
    a1 = mModel.getRootComponent().getChild(A.class);
    assertEquals(testValue, a1.getValue());
}
 
Example 16
Source File: ViewHierarchyTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testRemoveNewline() throws Exception {
    loggingOn();
    JEditorPane pane = ViewUpdatesTesting.createPane();
    Document doc = pane.getDocument();
    UndoManager undoManager = ViewUpdatesTesting.getUndoManager(doc);
    doc.insertString(0, "a\nb", null);
    doc.remove(1, 1);
    undoManager.undo();
    pane.modelToView(0);
}
 
Example 17
Source File: AbstractModelTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testSourceEditSyncUndo() throws Exception {
    defaultSetup();
    UndoManager urListener = new UndoManager();
    Document doc = mModel.getBaseDocument();
    mModel.addUndoableEditListener(urListener);
    
    mModel.startTransaction();
    B b2 = new B(mModel, 2);
    mModel.getRootComponent().addAfter(b2.getName(), b2, TestComponent3._A);
    mModel.endTransaction();
    assertEquals("first edit setup", 2, mModel.getRootComponent().getChildren(B.class).size());
    
    // see fix for issue 83963, with this fix we need coordinate edits from
    // on XDM model and on document buffer.  This reduce XDM undo/redo efficiency,
    // but is the best we can have to satisfy fine-grained text edit undo requirements.
    mModel.removeUndoableEditListener(urListener);
    doc.addUndoableEditListener(urListener);
    
    Util.setDocumentContentTo(doc, "resources/test2.xml");
    assertEquals("undo sync", 1, mModel.getRootComponent().getChildren(C.class).size());
    mModel.sync();
    doc.removeUndoableEditListener(urListener);
    
    assertEquals("sync setup", 1, mModel.getRootComponent().getChildren(B.class).size());
    assertEquals("sync setup", 0, mModel.getRootComponent().getChildren(C.class).size());
    
    // setDocumentContentTo did delete all, then insert, hence 2 undo's'
    urListener.undo(); urListener.undo(); 
    mModel.sync(); // the above undo's are just on document buffer, needs sync (inefficient).
    assertEquals("undo sync", 1, mModel.getRootComponent().getChildren(C.class).size());
    assertEquals("undo sync", 2, mModel.getRootComponent().getChildren(B.class).size());

    urListener.undo();
    assertEquals("undo first edit before sync", 1, mModel.getRootComponent().getChildren(B.class).size());

    urListener.redo();
    assertEquals("redo first edit", 1, mModel.getRootComponent().getChildren(C.class).size());
    assertEquals("redo first edit", 2, mModel.getRootComponent().getChildren(B.class).size());

    // needs to back track the undo's, still needs sync'
    urListener.redo(); urListener.redo();
    mModel.sync();
    assertEquals("redo to sync", 1, mModel.getRootComponent().getChildren(B.class).size());
    assertEquals("redo to sync", 0, mModel.getRootComponent().getChildren(C.class).size());
}
 
Example 18
Source File: NsPrefixCreationUndoTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Tests Issue #166177
 * @throws Exception
 */
public void testUndoNsPrefixCreation() throws Exception {
    defaultSetup();
    final UndoManager ur = new UndoManager();
    model.addUndoableEditListener(ur);
    A a = model.getRootComponent().getChild(A.class);
    //
    String xdmModelTextInitial = Util.getXdmBasedModelText(model);
    String xamModelTextInitial = Util.getXamBasedModelText(model);
    //
    // Add child component to A element
    model.startTransaction();
    try {
        TestComponent3.Aa newChildAa = new TestComponent3.Aa(model, 1);
        a.appendChild("setup", newChildAa);
    } finally {
        model.endTransaction();
    }
    //
    TestComponent3.Aa newAa = a.getChild(TestComponent3.Aa.class);
    assertEquals(TestComponent3.NS2_URI, newAa.getNamespaceURI());
    //
    String xdmModelTextAfterAdd = Util.getXdmBasedModelText(model);
    String xamModelTextAfterAdd = Util.getXamBasedModelText(model);
    //
    ur.undo();
    //
    // Check the XDM and XAM models' structure return back to initial state after undo.
    String xdmModelText = Util.getXdmBasedModelText(model);
    assertEquals(xdmModelText, xdmModelTextInitial);
    //
    String xamModelText = Util.getXamBasedModelText(model);
    assertEquals(xamModelText, xamModelTextInitial);
    //
    ur.redo();
    //
    xdmModelText = Util.getXdmBasedModelText(model);
    assertEquals(xdmModelText, xdmModelTextAfterAdd);
    //
    xamModelText = Util.getXamBasedModelText(model);
    assertEquals(xamModelText, xamModelTextAfterAdd);
    //
    ur.undo();
    //
    xdmModelText = Util.getXdmBasedModelText(model);
    assertEquals(xdmModelText, xdmModelTextInitial);
    //
    xamModelText = Util.getXamBasedModelText(model);
    assertEquals(xamModelText, xamModelTextInitial);
    //
}
 
Example 19
Source File: UndoRedoTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testIssue83963() throws Exception {
    SchemaModel model = Util.loadSchemaModel("resources/undoredo.xsd");
    BaseDocument doc = (BaseDocument) model.getModelSource().
            getLookup().lookup(BaseDocument.class);
    Schema s = model.getSchema();
    TestComponentListener listener = new TestComponentListener();
    model.addComponentListener(listener);
    UndoManager ur = new UndoManager();
    model.addUndoableEditListener(ur);
    
    String original = doc.getText(0, doc.getLength());
    //System.out.println("doc before add ComplexType"+doc.getText(0, doc.getLength()));
    GlobalComplexType gct = model.getFactory().createGlobalComplexType();
    model.startTransaction();
    s.addComplexType(gct);
    model.endTransaction();
    model.removeUndoableEditListener(ur);
    doc.addUndoableEditListener(ur);
    
    //System.out.println("doc after add ComplexType"+doc.getText(0, doc.getLength()));
    
    String stStr = "   <xsd:simpleType name=\"lend\">\n     <xsd:list>\n       <xsd:simpleType>\n         <xsd:restriction base=\"xsd:string\"/>\n       </xsd:simpleType>\n     </xsd:list>\n   </xsd:simpleType>";
    
    String afterInsert = doc.getText(0, doc.getLength());
    //System.out.println("doc after insert simpleType"+doc.getText(290, 10));
    // position was changing which is weird but doesn't matter for undo-redo testing
    int schemaTagPosition = afterInsert.length() - 10;
    doc.insertString(schemaTagPosition, "\n", null);
    model.sync();
    doc.insertString(schemaTagPosition + 1, stStr, null);
    model.sync();
    
    //System.out.println("doc after insert simpleType"+doc.getText(0, doc.getLength()));
    ur.undo();
    //System.out.println("doc after first undo"+doc.getText(0, doc.getLength()));
    ur.undo();
    assertEquals(afterInsert,doc.getText(0, doc.getLength()));
    //System.out.println("doc after second undo"+doc.getText(0, doc.getLength()));
    ur.undo();
    //System.out.println("doc after third undo"+doc.getText(0, doc.getLength()));
    assertEquals(original, doc.getText(0, doc.getLength()));
    
    ur.redo();
    assertEquals(afterInsert,doc.getText(0, doc.getLength()));
    //System.out.println("doc after first redo"+doc.getText(0, doc.getLength()));
    ur.redo();
    //System.out.println("doc after second redo"+doc.getText(0, doc.getLength()));
    ur.redo();
    //System.out.println("doc after third redo"+doc.getText(0, doc.getLength()));
}
 
Example 20
Source File: GlobalComponentsIndexTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Checks the index is created after reaching threshold amount of
 * global components and also the index removed if the amound goes down
 * below another threshold.
 */
@Test
public void testIndexCreationThreshold() throws Exception {
    SchemaModel sm;
    //
    // sm = Util.loadSchemaModel2("resources/performance2/B.xsd"); // NOI18N
    sm = Util.loadSchemaModel2("resources/performance2.zip", "B.xsd"); // NOI18N
    //
    assertTrue(sm.getState() == State.VALID);
    //
    assertTrue(sm instanceof SchemaModelImpl);
    SchemaModelImpl smImpl = SchemaModelImpl.class.cast(sm);
    GlobalComponentsIndexSupport indexSupport = smImpl.getGlobalComponentsIndexSupport();
    assertNotNull(indexSupport);
    GlobalComponentsIndexSupport.JUnitTestSupport testSupport =
            indexSupport.getJUnitTestSupport();
    assertNotNull(testSupport);
    //
    // Initiate index building
    GlobalElement found = sm.findByNameAndType("B000", GlobalElement.class);
    assertNotNull(found);
    Thread.sleep(500); // Wait the index is build
    //
    assertTrue(testSupport.isSupportIndex());
    int indexSise = testSupport.getIndexSize();
    assertEquals(indexSise, 90);
    //
    UndoManager um = new javax.swing.undo.UndoManager();
    AbstractDocumentModel.class.cast(sm).addUndoableEditListener(um);
    //
    sm.startTransaction();
    try {
        Schema schema = sm.getSchema();
        java.util.List<SchemaComponent> gChildren = schema.getChildren();
        int counter = 0;
        for (SchemaComponent child : gChildren) {
            //
            assertTrue(child instanceof GlobalElement);
            GlobalElement gElem = GlobalElement.class.cast(child);
            schema.removeElement(gElem);
            //
            counter++;
            if (counter >= 50) {
                break;
            }
        }
    } finally {
        sm.endTransaction();
    }
    //
    int childrenCount = sm.getSchema().getChildren().size();
    assertEquals(childrenCount, 40);
    assertFalse(testSupport.isSupportIndex());
    //
    //
    um.undo();
    //
    // Initiate index building again
    found = sm.findByNameAndType("B000", GlobalElement.class);
    assertNotNull(found);
    Thread.sleep(500); // Wait the index is build
    //
    assertTrue(testSupport.isSupportIndex());
    indexSise = testSupport.getIndexSize();
    assertEquals(indexSise, 90);
    //
    System.out.println("============================="); // NOI18N
    System.out.println(" testIndexCreationThreshold  "); // NOI18N
    System.out.println("=============LOG============="); // NOI18N
    String log = testSupport.printLog();
    System.out.print(log);
    System.out.println("============================="); // NOI18N
    //
}