public String getLabel(boolean checkVersion) {
   if (label == null && property != null) {
     if (checkVersion) {
       IBrandingService brandingService =
           (IBrandingService)
               GlobalServiceRegister.getDefault().getService(IBrandingService.class);
       boolean allowVerchange = brandingService.getBrandingConfiguration().isAllowChengeVersion();
       if (allowVerchange && property.getItem().isNeedVersion()) {
         label = property.getLabel() + " " + property.getVersion(); // $NON-NLS-1$
         return label;
       }
     }
     label = property.getLabel();
   }
   return label;
 }
 /** ldong Comment method "resetJobProblemList". */
 public static void resetJobProblemList(IRepositoryViewObject obj, String oldLabel) {
   if (obj == null) {
     return;
   }
   Property property = obj.getProperty();
   if (property == null || !(property.getItem() instanceof ProcessItem)) {
     return;
   }
   String newLabel = property.getLabel();
   if (!newLabel.equals(oldLabel)) {
     for (Iterator<Problem> iter = Problems.getProblemList().getProblemList().iterator();
         iter.hasNext(); ) {
       Problem problem = iter.next();
       if (problem instanceof TalendProblem) {
         TalendProblem routineProblem = (TalendProblem) problem;
         if (routineProblem.getJavaUnitName() != null
             && (routineProblem.getJavaUnitName().equals(oldLabel))) {
           // TDI-24683:if rename the jobItem,need clear the problem view to avoid use the old
           // problem list
           iter.remove();
         }
       }
     }
   }
 }
예제 #3
0
 public String getConnectionName() {
   DataManager connection = analysis.getContext().getConnection();
   if (connection == null) {
     return PluginConstant.EMPTY_STRING;
   } else {
     Property property = PropertyHelper.getProperty(connection);
     return property == null ? PluginConstant.EMPTY_STRING : property.getLabel();
   }
 }
  public String getItemName() {
    if (itemName == null) {
      IBrandingService brandingService =
          (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
      boolean allowVerchange = brandingService.getBrandingConfiguration().isAllowChengeVersion();
      ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(property.getItem());

      StringBuffer sb = new StringBuffer();
      if (itemType != null) {
        sb.append(itemType.toString());
        sb.append(' ');
      }
      sb.append(property.getLabel());

      if (allowVerchange) {
        sb.append(' ');
        sb.append(property.getVersion());
      }
      itemName = sb.toString();
    }
    return itemName;
  }
  /** cli Comment method "renameJobLaunch". */
  public static void renameJobLaunch(IRepositoryViewObject obj, String oldLabel) {
    if (obj == null) {
      return;
    }
    Property property = obj.getProperty();
    if (property == null || !(property.getItem() instanceof ProcessItem)) {
      return;
    }
    String newLabel = property.getLabel();
    if (!newLabel.equals(oldLabel)) {
      Project project = ProjectManager.getInstance().getProject(property);
      if (project == null) {
        return;
      }

      final String objProjectName = project.getLabel();
      final String id = property.getId();
      final String version = property.getVersion();

      ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
      if (launchManager == null) {
        return;
      }
      try {
        for (ILaunchConfiguration configuration : launchManager.getLaunchConfigurations()) {

          String jobId = configuration.getAttribute(TalendDebugUIConstants.JOB_ID, (String) null);
          String jobVersion =
              configuration.getAttribute(TalendDebugUIConstants.JOB_VERSION, (String) null);
          String projectName =
              configuration.getAttribute(
                  TalendDebugUIConstants.CURRENT_PROJECT_NAME, (String) null);

          // ILaunchConfigurationType type = launchManager
          // .getLaunchConfigurationType(TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE);
          ILaunchConfigurationType type = configuration.getType();
          if (type != null
              && TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE.equals(
                  type.getIdentifier())
              && objProjectName.equals(projectName)
              && id.equals(jobId)
              && version.equals(jobVersion)
              && type != null) {
            String displayName = newLabel + " " + jobVersion; // $NON-NLS-1$
            ILaunchConfigurationWorkingCopy workingCopy = configuration.getWorkingCopy();
            workingCopy.setAttribute(TalendDebugUIConstants.JOB_NAME, newLabel);
            // workingCopy.setAttribute(TalendDebugUIConstants.JOB_ID, jobId);
            // update to new version
            workingCopy.setAttribute(TalendDebugUIConstants.JOB_VERSION, jobVersion);
            // workingCopy.setAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, projectName);
            workingCopy.rename(displayName);
            workingCopy.doSave();
            break;
          }
        }
        clearUnusedLaunchs();
      } catch (CoreException e) {
        // nothing to do
      }
    }
  }