Exemplo n.º 1
0
  public void createEntryTextArea(
      final FlowPanel flowPanel, String entryStringBuilder, ScrollPanel scrollPanel) {

    String carriageReturn_LineFeed = "\r\n";
    String lines[] = entryStringBuilder.split("\\r?\\n");
    String stringBuilder = new String();

    for (int i = 0; i < lines.length; i++) {
      String line = lines[i];
      if (line.trim().startsWith("<criteriaReference")) {

        if (stringBuilder.length() > 0) {
          TextArea entryTextArea = new TextArea();
          entryTextArea.setStyleName("textarea_noborder");
          entryTextArea.addStyleName("entry_background");
          entryTextArea.setText(stringBuilder);
          flowPanel.add(entryTextArea);
          entryTextArea.setReadOnly(true);
          entryTextArea.setWidth("100%");
          entryTextArea.setHeight("100%");
          entryTextArea.setVisibleLines(getLineCount(stringBuilder) + 1);
        }

        stringBuilder = new String();

        // find more lines until the end tag </criteriaReference>
        String critRefStringBuilder = new String();
        while (!line.trim().startsWith("</criteriaReference>")) {
          critRefStringBuilder += (carriageReturn_LineFeed + line);
          i++;
          line = lines[i];
        }
        if (line.trim().startsWith("</criteriaReference>")) {
          critRefStringBuilder += (carriageReturn_LineFeed + line);
          createCritRefTextArea(flowPanel, scrollPanel, critRefStringBuilder);
        }
      } else {
        stringBuilder += (carriageReturn_LineFeed + line);
      }
    }
    if (stringBuilder.length() > 0) {
      TextArea entryTextArea = new TextArea();
      entryTextArea.setStyleName("textarea_noborder");
      entryTextArea.addStyleName("entry_background");
      entryTextArea.setText(stringBuilder);
      flowPanel.add(entryTextArea);
      entryTextArea.setReadOnly(true);
      entryTextArea.setWidth("100%");
      entryTextArea.setHeight("100%");
      entryTextArea.setVisibleLines(getLineCount(stringBuilder) + 1);
    }
  }
Exemplo n.º 2
0
  /** Constructor. */
  private ExportBox() {
    super(false);

    panel = new VerticalPanel();
    panel.getElement().getStyle().setMarginTop(1, Unit.EM);

    setHeadline(R.lang.Export());
    setDraggable(true);
    setWidth(WIDTH_PX + "px");

    btnExportXML = new Button(R.lang.exportInFile());
    btnExportXML.getElement().getStyle().setFloat(Float.RIGHT);
    btnExportXML.addClickHandler(this);

    btnClose = new Button(R.lang.Close());
    btnClose.getElement().getStyle().setMarginLeft(1, Unit.EM);
    btnClose.getElement().getStyle().setFloat(Float.RIGHT);
    btnClose.addClickHandler(this);

    textarea = new TextArea();
    textarea.setWidth((WIDTH_PX - 10) + "px");
    textarea.setHeight("200px");

    btnPanel = new FlowPanel();
    btnPanel.add(btnClose);
    btnPanel.add(btnExportXML);

    panel.add(textarea);
    panel.add(btnPanel);

    setContentWidget(panel);
  }
  /**
   * Creates a new debugger for the given editor.
   *
   * @param editor The WYSIWYG editor being debugged.
   */
  public WysiwygEditorDebugger(WysiwygEditor editor) {
    this.editor = editor;

    FlowPanel panel = new FlowPanel();
    panel.setWidth("100%");
    panel.add(editor.getUI());

    String width = "400px";
    String height = "220px";

    dirtyHTMLTextArea = new TextArea();
    dirtyHTMLTextArea.setWidth(width);
    dirtyHTMLTextArea.setHeight(height);
    panel.add(dirtyHTMLTextArea);

    cleanHTMLTextArea = new TextArea();
    cleanHTMLTextArea.setWidth(width);
    cleanHTMLTextArea.setHeight(height);
    panel.add(cleanHTMLTextArea);

    wikiTextArea = new TextArea();
    wikiTextArea.setWidth(width);
    wikiTextArea.setHeight(height);
    panel.add(wikiTextArea);

    eventsTextArea = new TextArea();
    eventsTextArea.setWidth(width);
    eventsTextArea.setHeight(height);
    panel.add(eventsTextArea);

    // get the transformed HTML Content
    dirtyHTMLTextArea.setText(editor.getRichTextEditor().getTextArea().getHTML());

    initWidget(panel);

    timer = new Timer();
    timer.addTimerListener(this);
    timer.scheduleRepeating(4000);
  }
Exemplo n.º 4
0
  public XmlFileWidget(final RuleAsset asset, final RuleViewer viewer) {
    super(asset, viewer);
    this.asset = asset;
    text = new TextArea();
    text.setHeight("300px");
    text.setWidth("600px");

    if (asset.content != null) {
      RuleContentText xmlContent = (RuleContentText) asset.content;
      text.setText(xmlContent.content);
    }

    layout.addRow(text);

    // TODO: add tree representation of the document
  }
  @Override
  public Widget createWidget() {
    container.setStyleName("fill-layout");

    OneToOneLayout panel =
        new OneToOneLayout()
            .setTitle("JSM Policy")
            .setHeadline("JSM Policy of the server")
            .setDescription("Java Security Manager policy file used on this server.")
            .setMaster("Policy of the server", container);

    textBoxName.setReadOnly(true);
    container.add(textBoxName);

    textAreaContent.setReadOnly(true);
    textAreaContent.setHeight("200px");
    container.add(textAreaContent);

    return panel.build();
  }
Exemplo n.º 6
0
  public void createCritRefTextArea(
      final FlowPanel flowPanel, final ScrollPanel scrollPanel, String critRefStringBuilder) {
    final TextArea critReftextArea = new TextArea();
    critReftextArea.setStyleName("textarea_noborder");
    critReftextArea.addStyleName("criteriaRef_background");
    critReftextArea.setText(critRefStringBuilder);
    flowPanel.add(critReftextArea);
    critReftextArea.setReadOnly(true);
    critReftextArea.setWidth("100%");
    critReftextArea.setHeight("100%");
    critReftextArea.setVisibleLines(critRefStringBuilder.split("\\r?\\n").length + 1);
    critReftextArea.setTitle("Double click to go see the entry.");

    critReftextArea.addDoubleClickHandler(
        new DoubleClickHandler() {

          @Override
          public void onDoubleClick(DoubleClickEvent event) {
            handleTextAreaClick(flowPanel, event, critReftextArea, scrollPanel);
          }
        });
  }
Exemplo n.º 7
0
  @UiHandler("getHyperlink")
  void getHyperlink(ClickEvent event) {
    MultiSelectionModel<SessionDataDto> sessionModel =
        (MultiSelectionModel) sessionsDataGrid.getSelectionModel();
    MultiSelectionModel<TaskDataDto> testModel =
        (MultiSelectionModel) testDataGrid.getSelectionModel();

    Set<SessionDataDto> sessions = sessionModel.getSelectedSet();

    Set<TaskDataDto> tests = testModel.getSelectedSet();

    Set<MetricNameDto> metrics = metricPanel.getSelected();

    TaskDataTreeViewModel taskDataTreeViewModel =
        (TaskDataTreeViewModel) taskDetailsTree.getTreeViewModel();
    Set<PlotNameDto> trends = taskDataTreeViewModel.getSelectionModel().getSelectedSet();

    HashSet<String> sessionsIds = new HashSet<String>();
    HashSet<TestsMetrics> testsMetricses = new HashSet<TestsMetrics>(tests.size());
    HashMap<String, TestsMetrics> map = new HashMap<String, TestsMetrics>(tests.size());

    for (SessionDataDto session : sessions) {
      sessionsIds.add(session.getSessionId());
    }

    for (TaskDataDto taskDataDto : tests) {
      TestsMetrics testsMetrics =
          new TestsMetrics(taskDataDto.getTaskName(), new HashSet<String>(), new HashSet<String>());
      testsMetricses.add(testsMetrics);
      map.put(taskDataDto.getTaskName(), testsMetrics);
    }

    for (MetricNameDto metricNameDto : metrics) {
      map.get(metricNameDto.getTests().getTaskName()).getMetrics().add(metricNameDto.getName());
    }

    for (PlotNameDto plotNameDto : trends) {
      map.get(plotNameDto.getTest().getTaskName()).getTrends().add(plotNameDto.getPlotName());
    }

    TrendsPlace newPlace =
        new TrendsPlace(
            mainTabPanel.getSelectedIndex() == 0
                ? NameTokens.SUMMARY
                : mainTabPanel.getSelectedIndex() == 1 ? NameTokens.TRENDS : NameTokens.METRICS);

    newPlace.setSelectedSessionIds(sessionsIds);
    newPlace.setSelectedTestsMetrics(testsMetricses);
    newPlace.setSessionTrends(sessionPlotPanel.getSelected());

    String linkText =
        Window.Location.getHost()
            + Window.Location.getPath()
            + Window.Location.getQueryString()
            + "#"
            + new JaggerPlaceHistoryMapper().getToken(newPlace);
    linkText = URL.encode(linkText);

    // create a dialog for copy link
    final DialogBox dialog = new DialogBox(false, true);
    dialog.setText("Share link");
    dialog.setModal(true);
    dialog.setAutoHideEnabled(true);
    dialog.setPopupPosition(event.getClientX(), event.getClientY());

    final TextArea textArea = new TextArea();
    textArea.setText(linkText);
    textArea.setWidth("300px");
    textArea.setHeight("40px");
    // select text
    Scheduler.get()
        .scheduleDeferred(
            new Scheduler.ScheduledCommand() {
              @Override
              public void execute() {
                textArea.setVisible(true);
                textArea.setFocus(true);
                textArea.selectAll();
              }
            });

    dialog.add(textArea);

    dialog.show();
  }
  private void createComponent() {
    hlBack = new Anchor("<<back");
    hlBack.addClickHandler(this);
    vPanel.add(hlBack);
    ProjectItems projectItems = currentUser.getProjectItems();
    if (projectItems.getProjectItemCount() == 0) {
      vPanel.add(new HTML("You are not subscribed to any projects."));
    } else {
      vPanel.add(form);
      lbProjects = new ListBox(false);
      lbProjects.addChangeHandler(this);
      vPanel.setSize("1000px", "500px");
      table.setCellSpacing(5);
      table.setCellPadding(0);
      table.setWidth("100%");
      tbName.setWidth("300px");
      // tbDescription.setWidth("300px");
      txtFileNotes.setHeight("75px");
      upload.setName("uploadFormElement");
      // fileUpload.setName("fileuploadFormElement");
      tbName.setName("name");
      tbDescription.setName("description");
      txtFileNotes.setName("notes");
      lbProjects.setName("projectDetails");
      btnSubmit.addClickHandler(this);
      txtWarnings.setStylePrimaryName("warnings");
      txtWarningDesc.setStylePrimaryName("warnings");
      txtFileNotes.setCharacterWidth(50);
      tbName.setMaxLength(50);
      // tbDescription.setMaxLength(255);
      // tbDescription.setText("");
      txtLogin = new TextBox();
      txtLogin.setName("user");
      txtLogin.setVisible(false);

      txtProject = new TextBox();
      txtProject.setName("projectName");
      txtProject.setVisible(false);

      int projectId = currentUser.getPreferredProjectId();

      for (int i = 0; i < projectItems.getProjectItemCount(); i++) {
        ProjectItem item = projectItems.getProjectItem(i);
        lbProjects.addItem(item.getProjectName(), String.valueOf(item.getProjectId()));
        if (projectId > 0) {
          if (projectId == item.getProjectId()) {
            lbProjects.setItemSelected(i, true);
          }
        } else {
          lbProjects.setItemSelected(0, true);
        }
      }

      table.setText(0, 0, "");
      table.setWidget(0, 1, txtWarnings);
      table.setText(1, 0, "");
      table.setWidget(1, 1, txtWarningDesc);
      table.setWidget(2, 0, new HTML("<b>Name:</b>&nbsp;&nbsp;&nbsp;"));
      table.setWidget(2, 1, tbName);
      table.setWidget(3, 0, new HTML("<b>File:</b>&nbsp;&nbsp;&nbsp;"));
      table.setWidget(3, 1, upload);
      // table.setWidget(4, 0, new HTML("<b>Description:</b>&nbsp;&nbsp;&nbsp;"));
      // table.setWidget(4, 1, fileUpload);
      table.setWidget(5, 0, new HTML("<b>Project:</b>&nbsp;&nbsp;&nbsp;"));
      table.setWidget(5, 1, lbProjects);
      table.setWidget(6, 0, new HTML("<b>Notes:</b>&nbsp;&nbsp;&nbsp;"));
      table.setWidget(6, 1, txtFileNotes);
      table.setWidget(7, 1, btnSubmit);
      table.setWidget(7, 2, txtLogin);
      table.setWidget(7, 3, txtProject);

      table.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(3, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(3, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(4, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(5, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(5, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(6, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(6, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(7, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(7, 0, HasVerticalAlignment.ALIGN_TOP);

      table.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(2, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(2, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(3, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(3, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(4, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(4, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(5, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(5, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(6, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(6, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(7, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(7, 1, HasVerticalAlignment.ALIGN_TOP);

      form.add(table);

      form.setAction(UPLOAD_ACTION_URL);
      form.setEncoding(FormPanel.ENCODING_MULTIPART);
      form.setMethod(FormPanel.METHOD_POST);

      form.addSubmitHandler(
          new FormPanel.SubmitHandler() {
            public void onSubmit(SubmitEvent event) {
              // This event is fired just before the form is submitted. We can
              // take this opportunity to perform validation.
              String fileName1 = upload.getFilename().trim();
              // String fileName2 = fileUpload.getFilename().trim();
              // System.out.println("File1: " + fileName1);
              if (fileName1.length() == 0 && tbName.getText().length() == 0) {
                txtWarnings.setHTML("*Please upload a file.");
                txtWarningDesc.setHTML("*Please enter the Job name.");
                event.cancel();
              }
              if ((fileName1.length() == 0) && tbName.getText().length() != 0) {
                txtWarnings.setText("");
                txtWarningDesc.setText("");
                txtWarnings.setHTML("*Please upload a file.");
                event.cancel();
              }
              if ((!(fileName1.length() == 0)) && tbName.getText().length() == 0) {
                txtWarnings.setText("");
                txtWarningDesc.setText("");
                txtWarnings.setHTML("*Please enter the Job name.");
                event.cancel();
              }
            }
          });

      form.addSubmitCompleteHandler(
          new FormPanel.SubmitCompleteHandler() {
            public void onSubmitComplete(SubmitCompleteEvent event) {
              txtFileNotes.setText("");
              txtWarningDesc.setText("");
              String sessionID = Cookies.getCookie("sid");
              if (sessionID != null) {
                String result = event.getResults();
                System.out.println("UploadJob Result: " + result);
                // Log.info("Result: " + result);
                String[] results = result.split("~");
                /*for(int i = 0; i < results.length; i++)
                {
                	 System.out.println(results[i]);
                	 try
                	 {
                		 jobId = Integer.parseInt(results[0]);
                	 }
                	 catch(NumberFormatException e)
                	 {
                		 e.printStackTrace();
                	 }
                }*/
                int jobId = -1;
                try {
                  jobId = Integer.parseInt(results[0]);
                } catch (NumberFormatException e) {
                  e.printStackTrace();
                }
                // Code modified
                if (jobId == 0) {
                  txtWarnings.setHTML(results[1]);
                }
                // Code modified
                // txtWarnings.setHTML(results[1]);

                else {
                  if (currentUser.getUsertype().equalsIgnoreCase("user")) {
                    History.newItem("userJobList");
                  } else {
                    if (tab == 0) {

                      History.newItem("adminJobList");
                    } else {
                      History.newItem("jobList");
                    }
                    // AdminPage adminPage = new AdminPage(tab);
                    // RootPanel.get("content").add(adminPage);
                  }
                }
              } else {
                Login login = new Login();
                login.displayLoginBox();
              }
            }
          });
    }
  }
Exemplo n.º 9
0
  private void makeBookMarks(FlowPanel flowPanel, TextArea textArea) {

    // TextArea firstTextArea = (TextArea) flowPanel.getWidget(0);

    // Check for data criteria section. This has Measure Details and the start of
    // dataCriteriaSection.
    // We need to break it up so that "Measure Details" and dataCriteriaSection are 2 different
    // textareas.

    String text = textArea.getText();
    int dataCritIndex = text.indexOf("<dataCriteriaSection>");
    if (dataCritIndex > -1) {
      String measureDetailsText = text.substring(0, dataCritIndex);
      String dataCritSection = text.substring(dataCritIndex);
      textArea.setText(measureDetailsText);
      textArea.setVisibleLines(getLineCount(measureDetailsText) + 3);

      TextArea dataCritTextArea = new TextArea();
      dataCritTextArea.setStyleName("textarea_noborder");
      dataCritTextArea.setText(dataCritSection);
      flowPanel.add(dataCritTextArea);
      dataCritTextArea.setReadOnly(true);
      dataCritTextArea.setWidth("100%");
      dataCritTextArea.setHeight("100%");
      dataCritTextArea.setVisibleLines(getLineCount(dataCritSection) + 3);

      flowPanel.insert(dataCritTextArea, flowPanel.getWidgetIndex(textArea) + 1);
      bookmarkMap.put("Data Criteria Section", dataCritTextArea);
    } else {
      // make sure the textarea does not have a style class of 'entry_background' and
      // 'criteriaRef_background',
      // find '<populationCriteriaSection>'.
      int isEntryTextArea = textArea.getStyleName().indexOf("entry_background");
      int isCritRefTextArea = textArea.getStyleName().indexOf("criteriaRef_background");

      if (isEntryTextArea == -1 && isCritRefTextArea == -1) {
        if (text.indexOf("<populationCriteriaSection>") > -1) {
          int extensionIndex = text.indexOf("<id extension=\"");
          if (extensionIndex > -1) {
            int startExtensionIndex = extensionIndex + "<id extension=\"".length();
            String extension =
                text.substring(startExtensionIndex, text.indexOf("\"", startExtensionIndex));
            System.out.println("Pop Crit Extension:" + extension);
            bookmarkMap.put(extension, textArea);
          }
        }
      }
    }

    // int textAreaCount = flowPanel.getWidgetCount();
    // Go through rest of the textAreas (from index 2) and for the textAreas which do
    // not have a style class of 'entry_background' and 'criteriaRef_background',
    // find '<populationCriteriaSection>'.

    // for(int i = 2;i < textAreaCount; i++){

    //			TextArea textArea = (TextArea) flowPanel.getWidget(i);
    //			int isEntryTextArea = textArea.getStyleName().indexOf("entry_background");
    //			int isCritRefTextArea = textArea.getStyleName().indexOf("criteriaRef_background");
    //
    //			if (isEntryTextArea == -1 && isCritRefTextArea == -1){
    //				if(textArea.getText().indexOf("<populationCriteriaSection>") > -1){
    //					String popCritText = textArea.getText();
    //					int extensionIndex = popCritText.indexOf("<id extension=\"");
    //					if(extensionIndex > -1){
    //						int startExtensionIndex = extensionIndex + "<id extension=\"".length();
    //						String extension = popCritText.substring(startExtensionIndex,
    // popCritText.indexOf("\"",startExtensionIndex));
    //						System.out.println("Pop Crit Extension:"+extension);
    //						bookmarkMap.put(extension, textArea);
    //					}
    //				}
    //			}

    // }

  }
Exemplo n.º 10
0
  private ScrollPanel getPanelForXML(String text) {

    String carriageReturn_LineFeed = "\r\n";

    final FlowPanel flowPanel = new FlowPanel();
    final ScrollPanel scrollPanel = new ScrollPanel();

    String lines[] = text.split("\\r?\\n");
    String stringBuilder = new String();
    for (int i = 0; i < lines.length; i++) {
      String line = lines[i];
      if (line.trim().startsWith("<criteriaReference")) {

        TextArea textArea = new TextArea();
        textArea.setStyleName("textarea_noborder");
        textArea.setText(stringBuilder);
        flowPanel.add(textArea);
        textArea.setReadOnly(true);
        textArea.setWidth("100%");
        textArea.setHeight("100%");
        textArea.setVisibleLines(getLineCount(stringBuilder) + 1);
        makeBookMarks(flowPanel, textArea);

        stringBuilder = new String();

        // find more lines until the end tag </criteriaReference>
        String critRefStringBuilder = new String();
        while (!line.trim().startsWith("</criteriaReference>")) {
          critRefStringBuilder += (carriageReturn_LineFeed + line);
          i++;
          line = lines[i];
        }
        if (line.trim().startsWith("</criteriaReference>")) {
          critRefStringBuilder += (carriageReturn_LineFeed + line);
          createCritRefTextArea(flowPanel, scrollPanel, critRefStringBuilder);
        }
      } else {
        String cleanLine = line.trim().replaceAll("<!--.*?-->", "");

        if (cleanLine.trim().startsWith("<entry")) {

          if (stringBuilder.length() > 0) {
            TextArea textArea = new TextArea();
            textArea.setStyleName("textarea_noborder");

            textArea.setEnabled(false);
            textArea.setWidth("100%");
            textArea.setHeight("100%");
            textArea.setText(stringBuilder);
            flowPanel.add(textArea);
            textArea.setVisibleLines(getLineCount(stringBuilder) + 1);
            makeBookMarks(flowPanel, textArea);
          }

          stringBuilder = new String();

          // find more lines until the end tag </criteriaReference>
          String entryStringBuilder = new String();
          while (!line.trim().startsWith("</entry>")) {
            entryStringBuilder += (carriageReturn_LineFeed + line);
            i++;
            line = lines[i];
          }
          if (line.trim().startsWith("</entry>")) {
            entryStringBuilder += (carriageReturn_LineFeed + line);

            createEntryTextArea(flowPanel, entryStringBuilder, scrollPanel);
          }
        } else {
          stringBuilder += (carriageReturn_LineFeed + line);
        }
      }
    }
    if (stringBuilder.trim().length() > 0) {
      TextArea textArea = new TextArea();
      textArea.setStyleName("textarea_noborder");
      textArea.setText(stringBuilder);
      flowPanel.add(textArea);
      textArea.setReadOnly(true);
      textArea.setWidth("100%");
      textArea.setHeight("100%");
      textArea.setVisibleLines(getLineCount(stringBuilder) + 1);
      makeBookMarks(flowPanel, textArea);
    }

    VerticalPanel vPanel = new VerticalPanel();
    vPanel.setWidth("100%");
    vPanel.setHeight("100%");

    vPanel.add(flowPanel);
    scrollPanel.add(vPanel);
    return scrollPanel;
  }
  private void init() {

    setModal(true);
    setAnimationEnabled(true);
    ensureDebugId("cwDialogBox");
    setText("New Recipe");

    // Create a table to layout the content
    VerticalPanel dialogContents = new VerticalPanel();
    setWidget(dialogContents);

    HorizontalPanel namePanel = new HorizontalPanel();
    namePanel.setSpacing(6);
    namePanel.add(new Label("Name:"));
    nameTextBox = new TextBox();
    nameTextBox.setWidth("600px");
    namePanel.add(nameTextBox);

    HorizontalPanel categoriesPanel = new HorizontalPanel();
    categoriesPanel.setSpacing(6);
    categoriesPanel.add(new Label("Category"));

    category.addItem("Fish");
    category.addItem("Meat");
    category.addItem("Poultry");
    categoriesPanel.add(category);

    categoriesPanel.add(new Label("Cuisine"));

    cuisine.addItem("American");
    cuisine.addItem("Mexican");
    cuisine.addItem("Italian");
    categoriesPanel.add(cuisine);

    categoriesPanel.add(new Label("Occasion"));

    occasion.addItem("Easter");
    occasion.addItem("Summer");
    occasion.addItem("Thanksgiving");
    categoriesPanel.add(occasion);

    categoriesPanel.add(new Label("Serves"));

    serves.addItem("1");
    serves.addItem("4");
    serves.addItem("12");
    serves.setItemSelected(1, true);
    categoriesPanel.add(serves);

    ingredients = new TextArea();
    ingredients.setTitle("Ingredients");
    ingredients.setHeight("200px");
    ingredients.setWidth("600px");

    Label ingredientsLabel = new Label("Ingredients");

    directions = new TextArea();
    directions.setTitle("Directions");
    directions.setHeight("200px");
    directions.setWidth("600px");

    Label directionsLabel = new Label("Directions");

    FlexTable grid = new FlexTable();
    grid.setWidget(0, 0, ingredientsLabel);
    grid.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
    grid.getCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);
    grid.setWidget(0, 1, ingredients);
    dialogContents.add(namePanel);
    grid.setWidget(1, 0, directionsLabel);
    grid.setWidget(1, 1, directions);
    dialogContents.setCellHeight(namePanel, "50px");
    dialogContents.add(categoriesPanel);
    dialogContents.setCellHeight(namePanel, "50px");
    dialogContents.add(grid);

    // Add a close button at the bottom of the dialog
    Button closeButton =
        new Button(
            "Close",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                hide();
              }
            });

    Button createButton =
        new Button(
            "Create Recipe",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                GWT.log("Creating Recipe: " + nameTextBox.getText(), null);
                addRecipe(
                    new RecipeTO(
                        nameTextBox.getText(),
                        category.getValue(category.getSelectedIndex()),
                        cuisine.getValue(cuisine.getSelectedIndex()),
                        occasion.getValue(occasion.getSelectedIndex()),
                        serves.getValue(serves.getSelectedIndex()),
                        ingredients.getText(),
                        directions.getText()));
                hide();
              }
            });

    Button saveButton =
        new Button(
            "Save Recipe",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                GWT.log("Updating Recipe: " + nameTextBox.getText(), null);
                updateRecipe(
                    new RecipeTO(
                        nameTextBox.getText(),
                        category.getValue(category.getSelectedIndex()),
                        cuisine.getValue(cuisine.getSelectedIndex()),
                        occasion.getValue(occasion.getSelectedIndex()),
                        serves.getValue(serves.getSelectedIndex()),
                        ingredients.getText(),
                        directions.getText()));
                hide();
                mainView.loadRecipes();
                RootPanel.get("stockList").remove(0);
                RootPanel.get("stockList").add(mainView);
                History.newItem("hoho");
              }
            });

    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    // Display update or create button if recipe exists and is being edited
    if (recipeExists) {
      buttonPanel.add(saveButton);
    } else {
      buttonPanel.add(createButton);
    }
    buttonPanel.add(closeButton);
    dialogContents.add(buttonPanel);

    // Return the dialog box
  }