public final void setNameText(final String name) {
   try {
     myNameDocument.replace(0, myNameDocument.getLength(), name, null);
   } catch (BadLocationException e) {
     LOG.error(e);
   }
 }
 public final String getNameText() {
   try {
     return myNameDocument.getText(0, myNameDocument.getLength());
   } catch (BadLocationException e) {
     LOG.error(e);
     return "";
   }
 }
  public void testGetText() throws Exception {
    PlainDocument doc = new PlainDocument();
    CharSequence text = DocumentUtilities.getText(doc);
    assertEquals(1, text.length());
    assertEquals('\n', text.charAt(0));

    text = DocumentUtilities.getText(doc);
    doc.insertString(0, "a\nb", null);
    for (int i = 0; i < doc.getLength() + 1; i++) {
      assertEquals(doc.getText(i, 1).charAt(0), text.charAt(i));
    }
  }
Ejemplo n.º 4
0
  /** Reads PounderModel from XML data on given InputStream. * */
  public PounderModel readModel(InputStream in) throws Exception {
    PounderData pd = read(in);
    PounderModel ret = new PounderModel();

    if (pd.testInstanceFactory != null)
      ret.getLoadedTestObjects().addElement(pd.testInstanceFactory.getSetupClass());

    ret.setTestInstanceFactory(pd.testInstanceFactory);
    ret.getRecord().addItems(pd.items);

    PlainDocument comment = ret.getComment();
    comment.remove(0, comment.getLength());
    if (pd.comment != null) comment.insertString(0, pd.comment, null);

    return ret;
  }
Ejemplo n.º 5
0
  /** Read data from given File and place it in given PounderModel. * */
  public void readToModel(PounderModel pm, File f) throws Exception {
    PounderData pd = read(new FileInputStream(f));
    PounderModel ret = new PounderModel();

    if (pd.testInstanceFactory != null)
      pm.getLoadedTestObjects().addElement(pd.testInstanceFactory.getSetupClass());

    pm.setTestInstanceFactory(pd.testInstanceFactory);
    pm.getRecord().clear();
    pm.getRecord().addItems(pd.items);
    pm.getFileModel().setFile(f);

    PlainDocument comment = pm.getComment();
    comment.remove(0, comment.getLength());
    if (pd.comment != null) comment.insertString(0, pd.comment, null);
  }