Example #1
0
 @Override
 public int category(Object element) {
   if (element instanceof RepositoryNode) {
     RepositoryNode node = (RepositoryNode) element;
     if (ERepositoryObjectType.METADATA_CON_COLUMN.equals(
         node.getProperties(EProperties.CONTENT_TYPE))) {
       RepositoryNode parent = node.getParent().getParent();
       if (parent != null
           && ERepositoryObjectType.METADATA_CON_TABLE.equals(
               parent.getProperties(EProperties.CONTENT_TYPE))
           && parent.getObject() instanceof MetadataTableRepositoryObject) {
         MetadataTableRepositoryObject tableObject =
             (MetadataTableRepositoryObject) parent.getObject();
         MetadataColumnRepositoryObject columnObject =
             (MetadataColumnRepositoryObject) ((RepositoryNode) element).getObject();
         MetadataColumn tColumn = columnObject.getTdColumn();
         EList<MetadataColumn> columns = tableObject.getTable().getColumns();
         for (int i = 0; i < columns.size(); i++) {
           MetadataColumn column = columns.get(i);
           if (column.getName() != null && column.getName().equals(tColumn.getName())) {
             return i;
           }
         }
       }
     }
   }
   return super.category(element);
 }
  /*
   * (non-Javadoc)
   *
   * @see org.talend.repository.tester.AbstractNodeTester#testProperty(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
   */
  @Override
  protected Boolean testProperty(
      Object receiver, String property, Object[] args, Object expectedValue) {
    if (receiver instanceof RepositoryNode) {
      RepositoryNode repositoryNode = (RepositoryNode) receiver;

      final ERepositoryObjectType propertyType = ERepositoryObjectType.METADATA_SAPCONNECTIONS;

      if (propertyType != null) {
        if (repositoryNode.getType() == ENodeType.STABLE_SYSTEM_FOLDER) {
          // stable folder(Queries,Table schemas, View schemas, Synonym schemas, Columns)
          Boolean parentTest =
              testProperty(repositoryNode.getParent(), property, args, expectedValue);
          if (parentTest != null) { // only do for the checked parent.
            return parentTest;
          }
        }

        boolean currentType = isTypeNode(repositoryNode, propertyType);
        /*
         * check the implication, such as query, schema, column,[CDC] etc
         */
        boolean schemaTest =
            checkImplicatedTeser(
                schemaTester,
                repositoryNode,
                ERepositoryObjectType.METADATA_SAP_FUNCTION,
                propertyType);

        return currentType || schemaTest;
      }
    }
    return null;
  }
 /**
  * DOC sgandon Comment method "getRepositoryNodeChildren".
  *
  * @param element
  * @param repositoryNode
  * @return
  */
 protected Object[] getRepositoryNodeChildren(RepositoryNode repositoryNode) {
   if (!repositoryNode.isInitialized()) {
     if (repositoryNode.getParent() instanceof ProjectRepositoryNode) {
       // initialize repository from main project
       initializeChildren(repositoryNode);
     } // else sub sub node so no need to initialize
     repositoryNode.setInitialized(true);
   } // else already initialised
   return repositoryNode.getChildren().toArray();
 }
Example #4
0
 private boolean isChildOfRecycleBin(RepositoryNode repositoryNode) {
   if (repositoryNode != null) {
     if (isRecycleBin(repositoryNode)) {
       return true;
     }
     if (isChildOfRecycleBin(repositoryNode.getParent())) {
       return true;
     }
   }
   return false;
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse
   * .jface.viewers.TreeViewer,
   * org.eclipse.jface.viewers.IStructuredSelection)
   */
  public void init(TreeViewer viewer, IStructuredSelection selection) {
    boolean canWork = !selection.isEmpty() && selection.size() == 1;
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    if (factory.isUserReadOnlyOnCurrentProject()) {
      canWork = false;
    }
    if (canWork) {
      Object o = selection.getFirstElement();
      RepositoryNode node = (RepositoryNode) o;
      switch (node.getType()) {
        case REPOSITORY_ELEMENT:
          if (node.getObjectType() != CamelRepositoryNodeType.repositoryRouteResourceType) {
            canWork = false;
          } else {
            IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
            IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
            if (repFactory.isPotentiallyEditable(node.getObject())) {
              this.setText(""); // $NON-NLS-1$
            } else {
              this.setText(""); // $NON-NLS-1$
            }
          }
          break;
        default:
          canWork = false;
      }
      RepositoryNode parent = node.getParent();
      if (canWork && parent != null && parent instanceof BinRepositoryNode) {
        canWork = false;
      }
      if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) {
        canWork = false;
      }

      // If the editProcess action canwork is true, then detect that the
      // job version is the latest verison or not.
      if (canWork) {
        canWork = isLastVersion(node);
      }
    }
    setEnabled(canWork);

    this.setText("Open another version");
    this.setToolTipText("Open another version");
    this.setImageDescriptor(
        RouteResourceActivator.createImageDesc("icons/open-another-version.png"));
  }
 /*
  * (non-Javadoc)
  *
  * @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
  * org.eclipse.jface.viewers.IStructuredSelection)
  */
 public void init(TreeViewer viewer, IStructuredSelection selection) {
   boolean canWork = !selection.isEmpty() && selection.size() == 1;
   RepositoryNode node = (RepositoryNode) selection.getFirstElement();
   if (canWork) {
     canWork =
         node.getType() == ENodeType.REPOSITORY_ELEMENT
             && node.getObject().getRepositoryObjectType() == ERepositoryObjectType.DOCUMENTATION;
   }
   RepositoryNode parent = null;
   if (node != null) {
     parent = node.getParent();
   }
   if (canWork && parent != null && parent instanceof BinRepositoryNode) {
     canWork = false;
   }
   setEnabled(canWork);
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.repository.ui.actions.metadata.AbstractCreateAction#init(org.talend.repository.model.RepositoryNode)
   */
  @Override
  protected void init(RepositoryNode node) {
    ERepositoryObjectType nodeType =
        (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    if (factory.isUserReadOnlyOnCurrentProject()
        || !ProjectManager.getInstance().isInCurrentMainProject(node)) {
      setEnabled(false);
    } else {
      if (ENodeType.REPOSITORY_ELEMENT.equals(node.getType())) {
        if (node.getObject().getRepositoryStatus() == ERepositoryStatus.DELETED
            || node.getObject().getRepositoryStatus() == ERepositoryStatus.LOCK_BY_OTHER) {
          setEnabled(false);
          return;
        }
        if ((factory.getStatus(node.getObject()) == ERepositoryStatus.DELETED)
            || (factory.getStatus(node.getObject()) == ERepositoryStatus.LOCK_BY_OTHER)) {
          setEnabled(false);
          return;
        }

        if (ERepositoryObjectType.METADATA_CON_TABLE.equals(nodeType)
            || ERepositoryObjectType.METADATA_CON_COLUMN.equals(nodeType)) {
          RepositoryNode parent = node.getParent();
          if (parent != null
              && HCatalogRepositoryNodeType.HCATALOG.equals(
                  parent.getProperties(EProperties.CONTENT_TYPE))) {
            setText(EDIT_LABEL);
            collectSiblingNames(node);
            setEnabled(true);
            return;
          }
        } else if (HCatalogRepositoryNodeType.HCATALOG.equals(nodeType)) {
          setText(CREATE_LABEL);
          collectChildNames(node);
          setEnabled(true);
          return;
        }
      }
    }
  }
 protected void initializeChildren(RepositoryNode parent) {
   ((ProjectRepositoryNode) parent.getParent()).initializeChildren(parent);
 }