コード例 #1
0
  public void tabSelected(TabItem item) {
    List<TabMapEntry> collection = spoon.delegates.tabs.getTabs();

    // See which core objects to show
    //
    for (TabMapEntry entry : collection) {
      if (item.equals(entry.getTabItem())) {
        // TabItemInterface itemInterface = entry.getObject();

        //
        // Another way to implement this may be to keep track of the
        // state of the core object tree in method
        // addCoreObjectsToTree()
        //
        if (entry.getObject() instanceof TransGraph || entry.getObject() instanceof JobGraph) {
          EngineMetaInterface meta = entry.getObject().getMeta();
          if (meta != null) {
            meta.setInternalKettleVariables();
          }
          if (spoon.getCoreObjectsState() != SpoonInterface.STATE_CORE_OBJECTS_SPOON) {
            spoon.refreshCoreObjects();
          }
        }
      }
    }

    // Also refresh the tree
    spoon.refreshTree();
    spoon.enableMenus();
  }
コード例 #2
0
  public String makeTabName(EngineMetaInterface transMeta, boolean showLocation) {
    if (Const.isEmpty(transMeta.getName()) && Const.isEmpty(transMeta.getFilename())) {
      return Spoon.STRING_TRANS_NO_NAME;
    }

    if (Const.isEmpty(transMeta.getName())
        || spoon.delegates.trans.isDefaultTransformationName(transMeta.getName())) {
      transMeta.nameFromFilename();
    }

    String name = "";

    if (showLocation) {
      if (!Const.isEmpty(transMeta.getFilename())) {
        // Regular file...
        //
        name += transMeta.getFilename() + " : ";
      } else {
        // Repository object...
        //
        name += transMeta.getRepositoryDirectory().getPath() + " : ";
      }
    }

    name += transMeta.getName();
    if (showLocation) {
      ObjectRevision version = transMeta.getObjectRevision();
      if (version != null) {
        name += " : r" + version.getName();
      }
    }
    return name;
  }
コード例 #3
0
  public void tabSelected(TabItem item) {
    ArrayList<TabMapEntry> collection = new ArrayList<TabMapEntry>(tabMap);

    // See which core objects to show
    //
    for (TabMapEntry entry : collection) {
      boolean isTrans = (entry.getObject() instanceof TransGraph);

      if (item.equals(entry.getTabItem())) {
        if (isTrans || entry.getObject() instanceof JobGraph) {
          EngineMetaInterface meta = entry.getObject().getMeta();
          if (meta != null) {
            meta.setInternalKettleVariables();
          }
          if (spoon.getCoreObjectsState() != SpoonInterface.STATE_CORE_OBJECTS_SPOON) {
            spoon.refreshCoreObjects();
          }
        }

        if (entry.getObject() instanceof JobGraph) {
          ((JobGraph) entry.getObject()).setFocus();
        } else if (entry.getObject() instanceof TransGraph) {
          ((TransGraph) entry.getObject()).setFocus();
        }

        break;
      }
    }

    // Also refresh the tree
    spoon.refreshTree();
    spoon.setShellText(); // calls also enableMenus() and markTabsChanged()
  }
コード例 #4
0
 /**
  * Finds the tab for the transformation that matches the metadata provided (either the file must
  * be the same or the repository id).
  *
  * @param trans Transformation metadata to look for
  * @return Tab with transformation open whose metadata matches {@code trans} or {@code null} if no
  *     tab exists.
  * @throws KettleFileException If there is a problem loading the file object for an open
  *     transformation with an invalid a filename.
  */
 public TabMapEntry findTabForTransformation(TransMeta trans) throws KettleFileException {
   // File for the transformation we're looking for. It will be loaded upon first request.
   FileObject transFile = null;
   for (TabMapEntry entry : tabMap) {
     if (entry == null || entry.getTabItem().isDisposed()) {
       continue;
     }
     if (trans.getFilename() != null && entry.getFilename() != null) {
       // If the entry has a file name it is the same as trans iff. they originated from the same
       // files
       FileObject entryFile = KettleVFS.getFileObject(entry.getFilename());
       if (transFile == null) {
         transFile = KettleVFS.getFileObject(trans.getFilename());
       }
       if (entryFile.equals(transFile)) {
         return entry;
       }
     } else if (trans.getObjectId() != null && entry.getObject() != null) {
       EngineMetaInterface meta = entry.getObject().getMeta();
       if (meta != null && trans.getObjectId().equals(meta.getObjectId())) {
         // If the transformation has an object id and the entry shares the same id they are the
         // same
         return entry;
       }
     }
   }
   // No tabs for the transformation exist and are not disposed
   return null;
 }