@Override
 public boolean isEnabled(final AbstractNode obj) {
   if (obj instanceof AbstractPackageNode) {
     return ((AbstractPackageNode) obj).getView().isEnabled();
   }
   return obj.isEnabled();
 }
Example #2
0
 @Override
 public boolean isEnabled(AbstractNode obj) {
   if (obj instanceof FilePackage) {
     return ((FilePackage) obj).getView().isEnabled();
   }
   if (obj instanceof CrawledPackage) {
     return ((CrawledPackage) obj).getView().isEnabled();
   }
   return obj.isEnabled();
 }
 public static File getDownloadDirectory(AbstractNode node) {
   String directory = null;
   if (node instanceof DownloadLink) {
     FilePackage parent = ((DownloadLink) node).getFilePackage();
     if (parent != null) directory = parent.getDownloadDirectory();
   } else if (node instanceof FilePackage) {
     directory = ((FilePackage) node).getDownloadDirectory();
   } /* else if (node instanceof CrawledLink) {
         CrawledPackage parent = ((CrawledLink) node).getParentNode();
         if (parent != null) directory = parent.getDownloadFolder();
     } else if (node instanceof CrawledPackage) {
         directory = ((CrawledPackage) node).getDownloadFolder();
     }*/ else throw new WTFException("Unknown Type: " + node.getClass());
   return getDownloadDirectory(directory);
 }
  @Override
  protected void setStringValue(final String value, final AbstractNode object) {
    if (StringUtils.isEmpty(value) || object == null) {
      return;
    }
    File oldPath = LinkTreeUtils.getDownloadDirectory(object);
    File newPath = LinkTreeUtils.getDownloadDirectory(value, null, object);
    if (oldPath.equals(newPath)) {
      /* both paths are same, so nothing to do */
      return;
    }
    if (object instanceof CrawledPackage) {
      LinkCollector.getInstance()
          .getQueue()
          .add(
              new QueueAction<Object, RuntimeException>(
                  org.appwork.utils.event.queue.Queue.QueuePriority.HIGH) {
                @Override
                protected Object run() {
                  ((CrawledPackage) object).setDownloadFolder(value);
                  return null;
                }
              });
      return;
    } else if (object instanceof CrawledLink) {
      final CrawledPackage p = ((CrawledLink) object).getParentNode();
      try {
        Dialog.getInstance()
            .showConfirmDialog(
                Dialog.LOGIC_DONOTSHOW_BASED_ON_TITLE_ONLY | Dialog.STYLE_SHOW_DO_NOT_DISPLAY_AGAIN,
                _JDT.T.SetDownloadFolderAction_actionPerformed_(p.getName()),
                _JDT.T.SetDownloadFolderAction_msg(p.getName(), 1),
                null,
                _JDT.T.SetDownloadFolderAction_yes(),
                _JDT.T.SetDownloadFolderAction_no());
        LinkCollector.getInstance()
            .getQueue()
            .add(
                new QueueAction<Object, RuntimeException>(
                    org.appwork.utils.event.queue.Queue.QueuePriority.HIGH) {
                  @Override
                  protected Object run() {
                    p.setDownloadFolder(value);
                    return null;
                  }
                });
        return;
      } catch (DialogClosedException e) {
        return;
      } catch (DialogCanceledException e) {
        /* user clicked no */
      }

      final CrawledPackage pkg = new CrawledPackage();
      pkg.setExpanded(CFG_LINKCOLLECTOR.CFG.isPackageAutoExpanded());
      if (TYPE.NORMAL != p.getType()) {
        final String pkgName;
        if (object instanceof AbstractPackageNode) {
          pkgName =
              LinknameCleaner.cleanFileName(
                  object.getName(),
                  false,
                  true,
                  LinknameCleaner.EXTENSION_SETTINGS.REMOVE_KNOWN,
                  true);
        } else {
          pkgName =
              LinknameCleaner.cleanFileName(
                  object.getName(),
                  false,
                  true,
                  LinknameCleaner.EXTENSION_SETTINGS.REMOVE_ALL,
                  true);
        }
        pkg.setName(pkgName);
      } else {
        pkg.setName(p.getName());
      }
      pkg.setComment(p.getComment());
      pkg.setDownloadFolder(value);

      final java.util.List<CrawledLink> links = new ArrayList<CrawledLink>();
      links.add((CrawledLink) object);
      LinkCollector.getInstance()
          .getQueue()
          .add(
              new QueueAction<Object, RuntimeException>(
                  org.appwork.utils.event.queue.Queue.QueuePriority.HIGH) {

                @Override
                protected Object run() {
                  LinkCollector.getInstance().moveOrAddAt(pkg, links, -1);
                  return null;
                }
              });
    }
  }
 @Override
 public boolean isEnabled(AbstractNode obj) {
     return obj.isEnabled();
 }
Example #6
0
 @Override
 protected Date getDate(AbstractNode node, Date date) {
   if (node.getCreated() <= 0) return null;
   date.setTime(node.getCreated());
   return date;
 }