Ejemplo n.º 1
0
 /** _more_ */
 public void checkPattern() {
   String pattern = getPatternWidget().getText().trim();
   File dir = new File(getFilePathWidget().getText().trim());
   File[] list =
       dir.listFiles(
           (java.io.FileFilter)
               new PatternFileFilter(pattern, false, getHiddenWidget().isSelected()));
   StringBuffer sb = new StringBuffer("<html>");
   if ((list == null) || (list.length == 0)) {
     sb.append("<h3><center><font color=\"red\">No files match the pattern</font></center></h3>");
     sb.append("Pattern: " + pattern + "<br>");
     list = dir.listFiles();
     if (list != null) {
       for (int i = 0; i < list.length; i++) {
         if (i == 0) {
           sb.append("<hr>Example Files:<br>");
         }
         if (i > 20) {
           sb.append("&nbsp;&nbsp;...<br>\n");
           break;
         }
         sb.append("&nbsp;&nbsp;" + list[i] + "<br>\n");
       }
     }
   } else {
     for (int i = 0; i < list.length; i++) {
       if (i == 0) {
         sb.append("<h3><center>Files that match</center></h3>\n");
       }
       if (i > 20) {
         sb.append("&nbsp;&nbsp;...<br>\n");
         break;
       }
       sb.append("&nbsp;&nbsp;" + list[i] + "<br>\n");
     }
   }
   sb.append("</html>");
   GuiUtils.showDialog("Sample files", GuiUtils.inset(new JLabel(sb.toString()), 5));
 }
Ejemplo n.º 2
0
  /**
   * _more_
   *
   * @param comps _more_
   * @param includeName _more_
   * @param includeFileCount _more_
   */
  public void getPropertyComponents(List comps, boolean includeName, boolean includeFileCount) {
    JButton directoryBtn = new JButton("Select");
    boolean isFile = false;
    if (getFile() != null) {
      File f = new File(getFile());
      isFile = f.isFile();
    }
    GuiUtils.setupFileChooser(directoryBtn, getFilePathWidget(), !isFile);
    if (isFile) {
      comps.add(GuiUtils.rLabel("File: "));
    } else {
      comps.add(GuiUtils.rLabel("Directory: "));
    }
    comps.add(
        GuiUtils.left(
            GuiUtils.centerRight(
                GuiUtils.wrap(getFilePathWidget()),
                GuiUtils.inset(directoryBtn, new Insets(0, 5, 0, 0)))));

    if (includeName) {
      comps.add(GuiUtils.rLabel("Name: "));
      comps.add(GuiUtils.left(getNameWidget()));
    }

    comps.add(GuiUtils.rLabel("File Pattern:"));
    comps.add(
        GuiUtils.left(
            GuiUtils.hbox(
                GuiUtils.wrap(GuiUtils.hbox(getPatternWidget(), getHiddenWidget())),
                GuiUtils.makeButton("Verify", this, "checkPattern"))));

    if (includeFileCount) {
      ActionListener actionListener =
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              checkModeEnabled();
            }
          };
      comps.add(GuiUtils.rLabel("Files:"));
      fileCountButton = new JRadioButton("", mode == MODE_COUNT);
      dateRangeButton = new JRadioButton("All files in last:", mode == MODE_ABSDATERANGE);
      fileCountButton.addActionListener(actionListener);
      dateRangeButton.addActionListener(actionListener);
      ButtonGroup bg = GuiUtils.buttonGroup(fileCountButton, dateRangeButton);
      List modeComps = new ArrayList();
      modeComps.add(fileCountButton);
      modeComps.add(getFileCountWidget());
      modeComps.add(new JLabel("  "));
      modeComps.add(dateRangeButton);
      modeComps.add(getDateRangeWidget());
      modeComps.add(new JLabel(" minutes"));
      checkModeEnabled();
      comps.add(GuiUtils.left(GuiUtils.hbox(modeComps)));
    }

    comps.add(GuiUtils.rLabel("Polling:"));
    comps.add(
        GuiUtils.left(
            GuiUtils.hbox(
                getActiveWidget(),
                GuiUtils.lLabel("     Check every: "),
                GuiUtils.wrap(getIntervalWidget()),
                GuiUtils.lLabel(" minutes"))));
  }