Пример #1
0
  private FlexTable getFooter() {

    ft = new FlexTable();
    ft.addStyleName("perunFooter");

    FlexTable.FlexCellFormatter ftf = ft.getFlexCellFormatter();

    if (!voContact.getHTML().isEmpty()) {
      // show only if any contact is present
      voContact.setHTML(
          "<strong>"
              + ApplicationMessages.INSTANCE.supportContact()
              + "</strong> "
              + voContact.getHTML());
    }

    ft.setWidget(0, 0, voContact);
    ft.setWidget(0, 1, new HTML(PerunWebConstants.INSTANCE.footerPerunCopyright()));

    ftf.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);
    ftf.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
    ftf.getElement(0, 1).setAttribute("style", "text-wrap: avoid;");
    ftf.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT);
    ftf.setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE);

    return ft;
  }
Пример #2
0
  private Widget appendComment(DiscussionRecord r) {
    SmallLabel hrd =
        new SmallLabel(constants.smallCommentBy0On1Small(r.author, new Date(r.timestamp)));
    hrd.addStyleName("discussion-header");
    commentList.add(hrd);

    String[] parts = r.note.split("\n");

    if (parts.length > 0) {
      StringBuilder txtBuilder = new StringBuilder();
      for (int i = 0; i < parts.length; i++) {
        txtBuilder.append(parts[i]);
        if (i != parts.length - 1) {
          txtBuilder.append("<br/>");
        }
      }
      HTML hth = new HTML(txtBuilder.toString());
      hth.setStyleName("form-field");
      commentList.add(hth);
    } else {
      Label lbl = new Label(r.note);
      lbl.setStyleName("form-field");
      commentList.add(lbl);
    }

    commentList.add(new HTML("<br/>"));
    return hrd;
  }
Пример #3
0
  /**
   * Populate a SWT Combo with HTML doctypes
   *
   * @param c
   */
  public void populateHTMLCombo(Combo c) {

    for (HTML entry : HTML.values()) {
      c.add(entry.getDisplayString());
    }

    selectHTMLDocTypePreference(c);
  }
Пример #4
0
 private void displayMessage(final String message) {
   if (message != null && !message.isEmpty()) {
     messageDisplay.setHTML(wrapDisplayMessage(message));
     messageDisplay.setVisible(true);
   } else {
     messageDisplay.setVisible(false);
   }
 }
Пример #5
0
  /**
   * Return HTML to insert for selected html/xhtml doc type
   *
   * @param displayString
   * @return selected doc type or HTML.TRANSITIONAL_XHTML10
   */
  public HTML getHTMLForDisplayString(String displayString) {
    for (HTML entry : HTML.values()) {

      if (displayString.equals(entry.getDisplayString())) {
        return entry;
      }
    }

    return HTML.TRANSITIONAL_XHTML10;
  }
Пример #6
0
  @Override
  protected Widget createMainWidget() {
    VerticalPanel panel = new VerticalPanel();
    panel.setStyleName(ThemeStyles.INSTANCE.fileUploadPanel());

    // directory panel
    HorizontalPanel directoryPanel = new HorizontalPanel();
    directoryPanel.setWidth("100%");
    directoryPanel.setStyleName(ThemeStyles.INSTANCE.fileUploadField());

    // directory name (informational field)
    panel.add(new Label("Target directory:"));
    directoryNameWidget_ = new DirectoryNameWidget();
    directoryNameWidget_.setDirectory(targetDirectory_);
    directoryPanel.add(directoryNameWidget_);

    // browse directory button
    // JJA: removed browse button (was causing confusion for users who
    // thought it was what they should press to browse local files)
    /*
    Button browseButton = new Button("Browse...",
                                     new BrowseDirectoryClickHandler());
    browseButton.getElement().getStyle().setMarginRight(5, Unit.PX);
    directoryPanel.add(browseButton);
    directoryPanel.setCellHorizontalAlignment(
                                        browseButton,
                                        HasHorizontalAlignment.ALIGN_RIGHT);
    */
    panel.add(directoryPanel);

    // filename field
    panel.add(new Label("File to upload:"));
    fileUpload_ = new FileUpload();
    fileUpload_.setStyleName(ThemeStyles.INSTANCE.fileUploadField());
    fileUpload_.setName("file");
    panel.add(fileUpload_);

    // zip file tip field
    HTML tip =
        new HTML(
            "<b>TIP</b>: To upload multiple files or a "
                + "directory, create a zip file. The zip file will "
                + "be automatically expanded after upload.");
    tip.addStyleName(ThemeStyles.INSTANCE.fileUploadField());
    tip.addStyleName(ThemeStyles.INSTANCE.fileUploadTipLabel());
    panel.add(tip);

    // target directory hidden field
    targetDirectoryHidden_ = new Hidden("targetDirectory", targetDirectory_.getPath());
    panel.add(targetDirectoryHidden_);

    return panel;
  }
Пример #7
0
  private void getImgLinks(HTML dequeuedHtml) {
    // TODO Auto-generated method stub
    String[] allValidExtension = m_ConfigData.getImageExtensions();
    StringBuilder extenstionAddToRegex = new StringBuilder();
    extenstionAddToRegex.append("(");
    for (int i = 0; i < allValidExtension.length; i++) {
      if (i == allValidExtension.length - 1) {
        extenstionAddToRegex.append(allValidExtension[i].toLowerCase() + "|");
        extenstionAddToRegex.append(allValidExtension[i].toUpperCase() + ")");
      } else {
        extenstionAddToRegex.append(allValidExtension[i].toLowerCase() + "|");
        extenstionAddToRegex.append(allValidExtension[i].toUpperCase() + "|");
      }
    }

    String regex = "<(img|IMG)\\s+(src|SRC)=\"(.*?\\." + extenstionAddToRegex.toString() + ")\"";
    System.out.println("Regex for image is " + regex);
    Pattern pattern = Pattern.compile(regex);
    Matcher m = pattern.matcher(dequeuedHtml.GetBody());
    System.out.println("fetching  image links");
    while (m.find()) {
      String link = m.group(3);
      System.out.println("enqueue to Downloader: " + link);
      if (!m_AllTraversedLinks.Exists(link)) {
        // m_DownloadQueue.enqueue(link);
        m_DownloadQueue.enqueue(link);
        // m_AllTraversedLinks.enqueue(link);
        System.out.println("Analyzer: adding image link: " + link);
      }
    }
    System.out.println("Done with fetching image links");
  }
Пример #8
0
 private void handleCaseOfImage(HTML dequeuedHtml) {
   // TODO Auto-generated method stub
   int contentLength = extractContentLength(dequeuedHtml);
   if (contentLength != -1) {
     synchronized (m_ResultWrapper.m_ImageAggregator) {
       m_ResultWrapper.m_ImageAggregator.m_NumOfImages++;
       m_ResultWrapper.m_ImageAggregator.m_TotalSizeInBytes += contentLength;
     }
   } else {
     System.out.println(dequeuedHtml.GetHeader() + " will not be aggregated!!!");
   }
   // int ContentLength = -1;
   // String regex = "Content-Length:\\s+([\\d]*)";
   // Pattern pat = Pattern.compile(regex);
   // Matcher m = pat.matcher(dequeuedHtml.GetHeader());
   // if (m.find()) {
   // try {
   // ContentLength = Integer.parseInt(m.group(1));
   // System.out.println("content length is: " + ContentLength);
   // // TODO: saveSomewhere
   // synchronized (m_ResultWrapper.m_ImageAggregator) {
   // m_ResultWrapper.m_ImageAggregator.m_NumOfImages++;
   // m_ResultWrapper.m_ImageAggregator.m_TotalSizeInBytes +=
   // ContentLength;
   // }
   // } catch (NumberFormatException e) {
   // // TODO: handle exception
   // System.out.println("Could not parse Content-Lenght header is malformed\n"
   // + dequeuedHtml.GetHeader());
   // }
   // }
 }
Пример #9
0
  private void HandleHTML(HTML dequeuedHtml, HTML.TypeOfHTML typeOfHtml) {
    int contentLenght = extractContentLength(dequeuedHtml);
    switch (typeOfHtml) {
      case TEXT:
        if (contentLenght != -1) {
          synchronized (m_ResultWrapper) {
            m_ResultWrapper.m_PageAggregator.m_NumOfPages++;
            m_ResultWrapper.m_PageAggregator.m_TotalSizeOfPagesInBytes += contentLenght;
          }
        }
        System.out.println("(Data of page was aggregated) content is text");
        getImgLinks(dequeuedHtml);
        getUrlLinks(dequeuedHtml); // TODO: can links have
        // HTTP:// ?
        break;
      case IMAGE:
        if (contentLenght != -1) {
          synchronized (m_ResultWrapper) {
            m_ResultWrapper.m_ImageAggregator.m_NumOfImages++;
            m_ResultWrapper.m_ImageAggregator.m_TotalSizeInBytes += contentLenght;
          }
        } else { // TODO: Delete this, deubgging purposes
          System.out.println(dequeuedHtml.GetHeader() + " will not be aggregated!!!");
        }
        break;

      default:
        break;
    }
  }
Пример #10
0
  /**
   * Pick the previous encoding preference else default to HTML.TRANSITIONAL_XHTML10
   *
   * @param c
   */
  public void selectHTMLDocTypePreference(Combo c) {
    String previousDocType = this.getDialogSettings().get(HTML_DOCTYPE_KEY);

    if (previousDocType != null && previousDocType.length() > 0) {
      int i = 0;
      for (HTML entry : HTML.values()) {
        if (previousDocType.equals(entry.getDisplayString())) {
          c.select(i);
          return;
        }
        i++;
      }
    }
    // default
    c.select(3);
  }
Пример #11
0
  private int extractContentLength(HTML dequeuedHtml) {
    int ContentLength = -1;
    String regex = "Content-Length:\\s+([\\d]*)";
    Pattern pat = Pattern.compile(regex);
    Matcher m = pat.matcher(dequeuedHtml.GetHeader());
    if (m.find()) {
      try {
        ContentLength = Integer.parseInt(m.group(1));
        System.out.println("content length is: " + ContentLength);
      } catch (NumberFormatException e) {
        // TODO: handle exception
        System.out.println(
            "Could not parse Content-Lenght, header is malformed\n" + dequeuedHtml.GetHeader());
      }
    }

    return ContentLength;
  }
Пример #12
0
  public void init(final KieImageType imageType, final int containersRunningCount) {
    if (imageType == null) return;

    final SafeUri imageUri = ClientUtils.getImageUri(imageType);
    typeNameText.setText(imageType.getName());
    if (containersRunningCount < 0) {
      countText.setVisible(false);
    } else if (containersRunningCount == 0
        && showCreateButton
        && !KieImageCategory.OTHERS.equals(imageType.getCategory())) {
      countText.setText(Constants.INSTANCE.createNew());
      countText.setTitle(Constants.INSTANCE.createNewForThisType());
      countText.addStyleName(style.createNewButton());
      countText.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent clickEvent) {
              KieImageTypeView.this.fireEvent(new CreateContainerEvent(imageType));
            }
          });
      countText.setVisible(true);
    } else {
      countText.setText(Integer.toString(containersRunningCount));
      countText.removeStyleName(style.createNewButton());
      countText.setVisible(true);
    }

    typeImage.setUrl(imageUri);
    typeImage.setSize(size, size);
    typeImage.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent clickEvent) {
            KieImageTypeView.this.fireEvent(new ImageTypeSelectedEvent(imageType));
          }
        });
    mainPanel.setVisible(true);
  }
Пример #13
0
 public void init() {
   super.init();
   searchWidget = new SearchWidget(watch);
   searchWidget.init();
   refreshImage = new Image(watch.getSkinFile(Constants.IMAGE_REFRESH));
   refreshImage.setStyleName(watch.getStyleName("titlebar", "refresh"));
   refreshImage.setTitle(watch.getTranslation("refresh"));
   refreshImage.addClickListener(
       new ClickListener() {
         public void onClick(Widget widget) {
           watch.refreshArticleList();
         }
       });
   title.setStyleName(watch.getStyleName("titlebar", "title"));
   panel.add(title);
   panel.add(refreshImage);
   panel.add(searchWidget);
   refreshData();
 }
Пример #14
0
 private void getUrlLinks(HTML dequeuedHtml) {
   // String regex = "<(a|A) (href|HREF)=\"(http|HTTP)://" + m_Domain +
   // "/(.*?)\">";
   String regex = "<(a|A)\\s+(href|HREF)=\"(?!#)(.*?)\">"; // TODO: do HTTP
   // prefix means
   // its external?
   Pattern pattern = Pattern.compile(regex);
   Matcher m = pattern.matcher(dequeuedHtml.GetBody());
   System.out.println("fetching links");
   while (m.find()) {
     String link = m.group(3);
     System.out.println("enqueue to Downloader: " + link);
     if (!m_AllTraversedLinks.Exists(link)) {
       // m_DownloadQueue.enqueue(link);
       m_DownloadQueue.enqueue(link);
       // m_AllTraversedLinks.enqueue(link);
       System.out.println("Analyzer: adding link: " + link);
     }
   }
   System.out.println("Done with fetching links");
 }
Пример #15
0
 private IReportVisitor createFormatter() throws IOException {
   final File file = new File(destination);
   if (HTML.equals(format)) {
     HTMLFormatter htmlFormatter = new HTMLFormatter();
     htmlFormatter.setFooterText(session.getDescription());
     return htmlFormatter.createVisitor(new FileMultiReportOutput(file));
   }
   final OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
   switch (format) {
     case HTMLZIP:
       final HTMLFormatter htmlFormatter = new HTMLFormatter();
       htmlFormatter.setFooterText(session.getDescription());
       return htmlFormatter.createVisitor(new ZipMultiReportOutput(out));
     case XML:
       final XMLFormatter xmlFormatter = new XMLFormatter();
       return xmlFormatter.createVisitor(out);
     case CSV:
       final CSVFormatter csvFormatter = new CSVFormatter();
       return csvFormatter.createVisitor(out);
     default:
       out.close();
       throw new AssertionError("Unexpected format " + format); // $NON-NLS-1$
   }
 }
Пример #16
0
 private void initMessage(final String message) {
   final RootPanel messagePanel = RootPanel.get("messagePlaceholder");
   messageDisplay.setVisible(false);
   messagePanel.add(messageDisplay);
   displayMessage(message);
 }
Пример #17
0
 public String getHTML() {
   return htmlWidget.getHTML();
 }
Пример #18
0
 public String getText() {
   return htmlWidget.getText();
 }
Пример #19
0
 public void setHTML(SafeHtml html) {
   htmlWidget.setHTML(html);
 }
Пример #20
0
 public void setText(String text) {
   htmlWidget.setText(text);
 }
Пример #21
0
 public static Tag create(RenderContext context, String name, boolean keepOpen) {
   return HTML.create(context).tag(name, keepOpen);
 }
Пример #22
0
 public static Tag create(Device device, String name, boolean keepOpen) {
   return HTML.create(device).tag(name, keepOpen);
 }
  public Widget draw() {

    titleWidget.setText(def.getName());
    final TabItem tab = this;

    // create main panel for content
    final FlexTable mainPage = new FlexTable();
    mainPage.setWidth("100%");

    final ExtendedTextBox description = new ExtendedTextBox();
    description.setWidth("100%");
    description.getTextBox().setText(def.getDescription());
    final ExtendedTextBox.TextBoxValidator validator =
        new ExtendedTextBox.TextBoxValidator() {
          @Override
          public boolean validateTextBox() {
            if (description.getTextBox().getText().trim().isEmpty()) {
              description.setError("Description can't be empty.");
              return false;
            }
            description.setOk();
            return true;
          }
        };

    final ExtendedTextBox displayName = new ExtendedTextBox();
    displayName.setWidth("100%");
    displayName.getTextBox().setText(def.getDisplayName());
    final ExtendedTextBox.TextBoxValidator validatorName =
        new ExtendedTextBox.TextBoxValidator() {
          @Override
          public boolean validateTextBox() {
            if (displayName.getTextBox().getText().trim().isEmpty()) {
              displayName.setError("Display name can't be empty.");
              return false;
            }
            displayName.setOk();
            return true;
          }
        };

    description.setValidator(validator);
    displayName.setValidator(validatorName);

    FlexTable attributeDetailTable = new FlexTable();
    attributeDetailTable.setStyleName("inputFormFlexTable");

    final CustomButton updateButton =
        TabMenu.getPredefinedButton(ButtonType.SAVE, "Save attribute details");
    updateButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {

            final ArrayList<AttributeRights> list = new ArrayList<AttributeRights>();
            for (AttributeRights r : rights) {
              if (r.getRole().equalsIgnoreCase("SELF")) {
                list.add(getRightsFromWidgets(selfRead, selfWrite, r));
              } else if (r.getRole().equalsIgnoreCase("VOADMIN")) {
                list.add(getRightsFromWidgets(voRead, voWrite, r));
              } else if (r.getRole().equalsIgnoreCase("GROUPADMIN")) {
                list.add(getRightsFromWidgets(groupRead, groupWrite, r));
              } else if (r.getRole().equalsIgnoreCase("FACILITYADMIN")) {
                list.add(getRightsFromWidgets(facilityRead, facilityWrite, r));
              }
            }

            if ((!def.getDescription().equals(description.getTextBox().getText().trim())
                || !def.getDisplayName().equals(displayName.getTextBox().getText().trim()))) {

              if (!validator.validateTextBox() || !validatorName.validateTextBox()) return;

              def.setDescription(description.getTextBox().getText().trim());
              def.setDisplayName(displayName.getTextBox().getText().trim());

              UpdateAttribute request =
                  new UpdateAttribute(
                      JsonCallbackEvents.disableButtonEvents(
                          updateButton,
                          new JsonCallbackEvents() {
                            @Override
                            public void onFinished(JavaScriptObject jso) {

                              // after update - update rights
                              SetAttributeRights request =
                                  new SetAttributeRights(
                                      JsonCallbackEvents.disableButtonEvents(
                                          updateButton,
                                          new JsonCallbackEvents() {
                                            @Override
                                            public void onFinished(JavaScriptObject jso) {
                                              enableDisableWidgets(true);
                                            }

                                            @Override
                                            public void onLoadingStart() {
                                              enableDisableWidgets(false);
                                            }

                                            @Override
                                            public void onError(PerunError error) {
                                              enableDisableWidgets(true);
                                            }
                                          }));
                              request.setAttributeRights(list);
                            }
                          }));
              request.updateAttribute(def);
            } else {

              // after update - update rights
              SetAttributeRights request =
                  new SetAttributeRights(
                      JsonCallbackEvents.disableButtonEvents(
                          updateButton,
                          new JsonCallbackEvents() {
                            @Override
                            public void onFinished(JavaScriptObject jso) {
                              enableDisableWidgets(true);
                            }

                            @Override
                            public void onLoadingStart() {
                              enableDisableWidgets(false);
                            }

                            @Override
                            public void onError(PerunError error) {
                              enableDisableWidgets(true);
                            }
                          }));
              request.setAttributeRights(list);
            }
          }
        });

    attributeDetailTable.setHTML(0, 0, "Display name:");
    attributeDetailTable.setWidget(0, 1, displayName);
    attributeDetailTable.setHTML(1, 0, "Description:");
    attributeDetailTable.setWidget(1, 1, description);
    for (int i = 0; i < attributeDetailTable.getRowCount(); i++) {
      attributeDetailTable.getFlexCellFormatter().setStyleName(i, 0, "itemName");
    }

    final FlexTable rightsTable = new FlexTable();
    rightsTable.setStyleName("inputFormFlexTable");

    rightsTable.setHTML(0, 1, "<strong>SELF</strong>");
    rightsTable.setHTML(0, 2, "<strong>VO</strong>");
    rightsTable.setHTML(0, 3, "<strong>GROUP</strong>");
    rightsTable.setHTML(0, 4, "<strong>FACILITY</strong>");

    rightsTable.setHTML(1, 0, "<strong>READ</strong>");
    rightsTable.setHTML(2, 0, "<strong>WRITE</strong>");

    rightsTable.setWidget(1, 1, selfRead);
    rightsTable.setWidget(2, 1, selfWrite);
    rightsTable.setWidget(1, 2, voRead);
    rightsTable.setWidget(2, 2, voWrite);
    rightsTable.setWidget(1, 3, groupRead);
    rightsTable.setWidget(2, 3, groupWrite);
    rightsTable.setWidget(1, 4, facilityRead);
    rightsTable.setWidget(2, 4, facilityWrite);

    rightsTable.addStyleName("centeredTable");

    TabMenu menu = new TabMenu();
    menu.addWidget(updateButton);

    menu.addWidget(
        TabMenu.getPredefinedButton(
            ButtonType.CLOSE,
            "",
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                session.getTabManager().closeTab(tab, false);
              }
            }));

    GetAttributeRights rightsCall =
        new GetAttributeRights(
            def.getId(),
            new JsonCallbackEvents() {
              @Override
              public void onFinished(JavaScriptObject jso) {
                rights = JsonUtils.jsoAsList(jso);
                for (AttributeRights r : rights) {
                  if (r.getRole().equalsIgnoreCase("SELF")) {
                    setRightsToWidgets(selfRead, selfWrite, r);
                  } else if (r.getRole().equalsIgnoreCase("VOADMIN")) {
                    setRightsToWidgets(voRead, voWrite, r);
                  } else if (r.getRole().equalsIgnoreCase("GROUPADMIN")) {
                    setRightsToWidgets(groupRead, groupWrite, r);
                  } else if (r.getRole().equalsIgnoreCase("FACILITYADMIN")) {
                    setRightsToWidgets(facilityRead, facilityWrite, r);
                  }
                }
                enableDisableWidgets(true);
                rightsTable.setVisible(true);
              }

              @Override
              public void onError(PerunError error) {
                enableDisableWidgets(true);
                rightsTable.setVisible(false);
              }

              @Override
              public void onLoadingStart() {
                enableDisableWidgets(false);
                rightsTable.setVisible(false);
              }
            });
    rightsCall.retrieveData();

    // create new instance for jsonCall
    final GetServicesByAttrDefinition services = new GetServicesByAttrDefinition(def.getId());
    services.setCheckable(false);

    CellTable<Service> attrDefTable =
        services.getTable(
            new FieldUpdater<Service, String>() {
              @Override
              public void update(int index, Service object, String value) {
                session.getTabManager().addTab(new ServiceDetailTabItem(object));
              }
            });
    attrDefTable.setStyleName("perun-table");
    ScrollPanel scrollTable = new ScrollPanel(attrDefTable);
    scrollTable.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(scrollTable, 350, this);

    // set content to page

    mainPage.setWidget(0, 0, menu);
    mainPage.getFlexCellFormatter().setColSpan(0, 0, 2);

    mainPage.setWidget(1, 0, attributeDetailTable);
    mainPage.setWidget(1, 1, rightsTable);
    mainPage.getFlexCellFormatter().setWidth(1, 0, "50%");
    mainPage.getFlexCellFormatter().setWidth(1, 1, "50%");

    HTML title = new HTML("<p>Required by service</p>");
    title.setStyleName("subsection-heading");
    mainPage.setWidget(2, 0, title);
    mainPage.getFlexCellFormatter().setColSpan(2, 0, 2);

    // put page into scroll panel
    mainPage.setWidget(3, 0, scrollTable);
    mainPage.getFlexCellFormatter().setColSpan(3, 0, 2);
    mainPage.getFlexCellFormatter().setHeight(3, 0, "100%");

    this.contentWidget.setWidget(mainPage);

    return getWidget();
  }
Пример #24
0
  @Override
  public void run() {

    while (ThreadManager.isRunning) { // m_DownloadQueue.getSize() !=0 ||
      // m_AnalyzeQueue.getSize() != 0) { // TODO: think about
      // this condition
      // HTML dequeuedHtml = m_AnalyzeQueue.dequeue();
      ThreadManager.updateStateAnalyzer(true);
      HTML dequeuedHtml = m_AnalyzeQueue.dequeue();
      if (dequeuedHtml != null) {
        ThreadManager.updateStateAnalyzer(false);
        System.out.println("Analyzer: dequeued: \n Header:\n" + dequeuedHtml.GetHeader());
        try {
          String contentTypeOfHtml =
              getContentTypeFromHeader(
                  dequeuedHtml.GetHeader()); // dequeuedHtml.GetContentType().toLowerCase();
          if (contentTypeOfHtml.contains(IMAGE)) { // in case of image
            // handle case of image
            System.out.println("Analzyer: it is an image");
            // TODO: check extension supported
            // handleCaseOfImage(dequeuedHtml);
            HandleHTML(dequeuedHtml, HTML.TypeOfHTML.IMAGE);

          } else if (contentTypeOfHtml.contains(VIDEO)) { // in case
            System.out.println("Analzyer: it is an video"); // of
            // Video
            // handle case of video
          } else if (contentTypeOfHtml.contains(DOCUMENT)) { // in
            // TODO: what is the command for document? <a href? <doc
            // src=? // case
            System.out.println("Analzyer: it is an document"); // //
            // of
            // Document
            // handle case of document
          } else if (contentTypeOfHtml.contains("text")) {
            HandleHTML(dequeuedHtml, HTML.TypeOfHTML.TEXT);
            // int contentLenght =
            // extractContentLength(dequeuedHtml); // TODO: should
            // be done in different method using enum
            // if (contentLenght != -1) {
            // synchronized (m_ResultWrapper) {
            // m_ResultWrapper.m_PageAggregator.m_NumOfPages++;
            // m_ResultWrapper.m_PageAggregator.m_TotalSizeOfPagesInBytes+=
            // contentLenght;
            // }
            // }
            // System.out.println("(Data of page was aggregated) content is text");
            // getImgLinks(dequeuedHtml);
            // getUrlLinks(dequeuedHtml); // TODO: can links have
            // HTTP:// ?
          } else {
            System.out.println("Downloader: Error in content type of " + dequeuedHtml.toString());
          }
        } catch (Exception e) {
          System.out.println("Couldnt get content type from: " + dequeuedHtml.GetHeader());
          System.out.println(e.getMessage());
          e.printStackTrace();
        }
      }
    }
    System.out.println("Analyzer Finished!");
    // m_DownloadQueue.unregisterProducer();

  }
Пример #25
0
 public void refreshData() {
   title.setHTML(watch.getTitleBarText());
 }