예제 #1
0
  public void execute(
      PluginNode pNode, DMConnection pCon, IDfPersistentObject[] pTargets, ALogger pLogger)
      throws Exception {

    for (int t = 0; t < pTargets.length; t++) {

      IDfSysObject obj = (IDfSysObject) pTargets[t];
      String id = obj.getObjectId().toString();
      String dql =
          "select f.dos_extension,f.name "
              + "FROM dm_sysobject (ALL) s, dmr_content r, dm_store t, dm_format f "
              + "WHERE r_object_id = ID('"
              + id
              + "') "
              + "AND ANY (parent_id=ID('"
              + id
              + "') AND page = 0) "
              + "AND r.storage_id=t.r_object_id "
              + "AND f.r_object_id=r.format";

      IDfQuery query = pCon.createQuery(dql);
      IDfCollection res = query.execute(pCon.getSession(), IDfQuery.READ_QUERY);

      while (res.next()) {

        try {
          String name = res.getString("name");
          pLogger.out.println(">>> " + name + "@" + ObjectTool.getName(obj));
          String ext = res.getString("dos_extension");
          ByteArrayInputStream stream = obj.getContentEx2(name, 0, null);
          String content = AFile.readFile(stream);
          stream.close();

          for (Enumeration i = properties.keys(); i.hasMoreElements(); ) {
            String key = (String) i.nextElement();
            content = content.replaceAll(key, properties.getProperty(key));
          }

          content = AFile.readFile(fileHeader) + content + AFile.readFile(fileFooter);

          File f =
              new File(
                  tmpDir,
                  obj.getObjectName()
                      + "_"
                      + obj.getString("language_code")
                      + "_"
                      + name
                      + "."
                      + ext);
          pLogger.out.println("--- WRITE: " + f.getAbsolutePath());
          AFile.writeFile(f, content);

        } catch (Exception e) {
          pLogger.out.println(e.toString());
        }
      }
      res.close();
    }
  }
예제 #2
0
  public void objectsChanged(int mode, IDfPersistentObject[] objects) {

    // String selected = (String)combo.getSelectedItem();

    for (int i = 0; i < objects.length; i++) {
      if (objects[i] instanceof IDfSysObject) {
        IDfSysObject sys = (IDfSysObject) objects[i];

        try {

          if (mode == ApiObjectChanged.DELETED) {
            tree.objectDelete(sys.getObjectId());
          } else {

            for (int j = 0; j < sys.getFolderIdCount(); j++) {
              IDfFolder folderObject =
                  (IDfFolder) con.getExistingObject(((IDfSysObject) objects[i]).getFolderId(j));

              String folder = folderObject.getString("r_folder_path");

              // if ( folder.startsWith( selected ) ||
              // "[All]".equals( selected ) ) {
              if (mode == ApiObjectChanged.CREATED) tree.objectAdd(objects[i]);
              else if (mode == ApiObjectChanged.CHANGED) tree.objectUpdate(objects[i]);
              // }
            }
          }
        } catch (DfException e) {
          e.printStackTrace();
        }
      }
    }
  }
예제 #3
0
  public void initPlugin(PluginNode pNode, PluginConfig pConfig) throws Exception {
    con = (DMConnection) pNode.getSingleApi(DMConnection.class);
    timer = ((ApiSystem) pNode.getSingleApi(ApiSystem.class)).getTimer();
    node = pNode;

    initUI();

    node.addApi(ApiObjectChanged.class, this);

    try {
      ((ApiLayout) pNode.getSingleApi(ApiLayout.class)).setComponent(this, pConfig.getNode());
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    if (pConfig.getNode().getAttribute("listen").indexOf("_obj.hotselect_") >= 0) {
      initHotSelectMenu(pNode, pConfig, this);
      pNode.addApi(ApiObjectHotSelect.class, this);
    }
    if (pConfig.getNode().getAttribute("listen").indexOf("_obj.last_") >= 0) {
      IDfPersistentObject obj = con.getPersistentObject(pConfig.getProperty("objid"));
      show(con, (IDfSysObject) obj);
    }

    findCabinets();
  }
예제 #4
0
  public void initPlugin(PluginNode pNode, PluginConfig pConfig) throws Exception {

    node = pNode;
    con = (DMConnection) pNode.getSingleApi(DMConnection.class);
    config = pConfig;

    initUI();

    ((ApiLayout) pNode.getSingleApi(ApiLayout.class)).setComponent(this, pConfig.getNode());

    if (pConfig.getNode().getAttribute("listen").indexOf("_obj.hotselect_") >= 0) {
      pNode.addApi(ApiObjectHotSelect.class, this);
    }
    if (pConfig.getNode().getAttribute("listen").indexOf("_obj.last_") >= 0) {
      IDfPersistentObject obj = con.getPersistentObject(pConfig.getProperty("objid"));
      actionShow(obj);
    }
  }
예제 #5
0
  public void selectedEvent(NodeValue[] value, int mode, JComponent src, int x, int y) {

    try {
      if (value == null) {
        if (mode == Listener.MODE_HOT_SELECT) {
          ApiObjectHotSelect[] list = (ApiObjectHotSelect[]) node.getApi(ApiObjectHotSelect.class);
          if (list == null) return;

          for (int i = 0; i < list.length; i++)
            try {
              list[i].apiObjectHotSelected(con, null, null);
            } catch (Throwable t) {
              t.printStackTrace();
            }
        }
        return;
      }

      final IDfPersistentObject[] obj = new IDfPersistentObject[value.length];
      final IDfPersistentObject[] parents = new IDfPersistentObject[value.length];

      for (int i = 0; i < value.length; i++) {
        obj[i] = con.getPersistentObject(value[i].getId());
        if (value[i].getParentId() != null)
          parents[i] = con.getPersistentObject(value[i].getParentId());
      }

      if (mode == Listener.MODE_HOT_SELECT) {
        final ApiObjectHotSelect[] list =
            (ApiObjectHotSelect[]) node.getApi(ApiObjectHotSelect.class);
        if (list == null) return;

        for (int i = 0; i < list.length; i++)
          try {
            if (!list[i].equals(TreePlugin.this)) list[i].apiObjectDepricated();
          } catch (Throwable t) {
            t.printStackTrace();
          }

        timer.schedule(
            new TimerTask() {

              public void run() {
                for (int i = 0; i < list.length; i++)
                  try {
                    if (!list[i].equals(TreePlugin.this))
                      list[i].apiObjectHotSelected(con, parents, obj);
                  } catch (Throwable t) {
                    t.printStackTrace();
                  }
              }
            },
            1);
      } else if (mode == Listener.MODE_SELECT) {
        /*
         * final ApiObjectSelect[] list =
         * (ApiObjectSelect[])node.getApi( ApiObjectSelect.class ); if (
         * list == null ) return;
         *
         * timer.schedule( new TimerTask() {
         *
         * public void run() { for ( int i = 0; i < list.length; i++ )
         * try { list[i].apiObjectSelected( con, obj ); } catch (
         * Throwable t ) { t.printStackTrace(); } }
         *
         * },1);
         */
      } else if (mode == Listener.MODE_MENU) {
        ObjectWorkerTool.showMenu(node, con, obj, src, x, y);
      }

    } catch (DfException e) {
      e.printStackTrace();
    }
  }