public IDesignerCoreService getDesignerCoreService() {
   if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
     IService service = GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
     return (IDesignerCoreService) service;
   }
   return null;
 }
 public static void saveResource() {
   if (isModified()) {
     String installLocation =
         new Path(Platform.getConfigurationLocation().getURL().getPath())
             .toFile()
             .getAbsolutePath();
     try {
       Resource resource = createComponentCacheResource(installLocation);
       resource.getContents().add(cache);
       EmfHelper.saveResource(cache.eResource());
     } catch (PersistenceException e1) {
       ExceptionHandler.process(e1);
     }
     ILibraryManagerService repositoryBundleService =
         (ILibraryManagerService)
             GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
     repositoryBundleService.clearCache();
     if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
       ILibrariesService libService =
           (ILibrariesService)
               GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
       if (libService != null) {
         libService.syncLibraries();
       }
     }
     setModified(false);
   }
 }
Beispiel #3
0
  @Override
  public void logOnProject(Project project) throws LoginException, PersistenceException {
    setLoggedOnProject(false);

    // TODO: review the prefs
    // new StatusPreferenceInitializer().initializeDefaultPreferences();
    IStatusPreferenceInitService statusPreferenceInitService =
        CoreRuntimePlugin.getInstance().getStatusPreferenceInitService();
    if (statusPreferenceInitService != null) {
      statusPreferenceInitService.initStatusPreference();
    }
    String productVersion = VersionUtils.getVersion();
    IBrandingService brandingService = null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IBrandingService.class)) {
      brandingService =
          (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    }
    if (brandingService != null) {
      String version = brandingService.getFullProductName() + "-" + productVersion; // $NON-NLS-1$
      if (!version.equals(project.getEmfProject().getProductVersion())) {
        project.getEmfProject().setProductVersion(version);
        project.getEmfProject().getFolders().clear();
      }
    }
    // saveProject();

    setLoggedOnProject(true);
  }
  @Override
  public void syncLibraries(IProgressMonitor... monitorWrap) {
    // TODO system routine libraries seems no use ,need to check more...
    // deploy system routine libraries
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerUIService.class)) {
      ILibraryManagerUIService libUiService =
          (ILibraryManagerUIService)
              GlobalServiceRegister.getDefault().getService(ILibraryManagerUIService.class);
      libUiService.initializeSystemLibs();
    }

    if (TalendCacheUtils.cleanComponentCache()) {
      repositoryBundleService.clearCache();
    }
    // Add a new system file, if exists, means all components libs are already setup, so no need to
    // do again.
    // if clean the component cache, it will automatically recheck all libs still.
    if (!repositoryBundleService.isInitialized()) {
      // 2. Components libraries
      if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsService.class)) {
        repositoryBundleService.deployComponentsLibs(monitorWrap);
        repositoryBundleService.setInitialized();
      }
    }

    checkInstalledLibraries();

    // clean the temp library of job needed in .java\lib
    cleanLibs();

    log.debug(Messages.getString("JavaLibrariesService.synchronization")); // $NON-NLS-1$
    isLibSynchronized = true;
  }
 @Override
 public void generateTestReports(IProgressMonitor monitor) throws Exception {
   if (!isOptionChoosed(ExportChoice.includeTestSource)) {
     return;
   }
   if (GlobalServiceRegister.getDefault()
       .isServiceRegistered(ITestContainerProviderService.class)) {
     ITestContainerProviderService testContainerService =
         (ITestContainerProviderService)
             GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
     if (testContainerService != null) {
       List<IFile> reports = new ArrayList<IFile>();
       List<ProcessItem> testsItems = testContainerService.getAllTestContainers(processItem);
       for (ProcessItem testItem : testsItems) {
         List<IFile> testReportFiles = testContainerService.getTestReportFiles(testItem);
         if (testReportFiles.size() > 0) {
           reports.add(testReportFiles.get(0));
         }
       }
       IFolder testsFolder = talendProcessJavaProject.getTestsFolder();
       talendProcessJavaProject.cleanFolder(monitor, testsFolder);
       IFolder parentFolder =
           talendProcessJavaProject.createSubFolder(
               monitor, testsFolder, processItem.getProperty().getLabel());
       for (IFile report : reports) {
         report.copy(parentFolder.getFile(report.getName()).getFullPath(), true, monitor);
       }
     }
   }
 }
  public static boolean checkIsInstallExternalJar() {
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerUIService.class)) {
      ILibraryManagerUIService libUiService =
          (ILibraryManagerUIService)
              GlobalServiceRegister.getDefault().getService(ILibraryManagerUIService.class);

      return libUiService.isModuleInstalledForBundle(REQUIRE_BUNDLE_NAME);
    }
    return false;
  }
 protected void refreshInFinish(boolean isModified) {
   if (isModified) {
     if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
       IDesignerCoreService service =
           (IDesignerCoreService)
               GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
       if (service != null) {
         service.refreshComponentView(connectionItem);
       }
     }
   }
 }
 private void addDQDependencies(IFolder parentFolder, List<Item> items) throws IOException {
   if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQItemService.class)) {
     ITDQItemService tdqItemService =
         (ITDQItemService) GlobalServiceRegister.getDefault().getService(ITDQItemService.class);
     for (Item item : items) {
       if (tdqItemService != null
           && tdqItemService.hasProcessItemDependencies(Arrays.asList(new Item[] {item}))) {
         // add .Talend.definition file
         String defIdxFolderName = "TDQ_Libraries"; // $NON-NLS-1$
         String defIdxFileName = ".Talend.definition"; // $NON-NLS-1$
         Project pro = getProject(processItem);
         IFolder itemsProjectFolder =
             parentFolder.getFolder(pro.getTechnicalLabel().toLowerCase());
         File itemsFolderDir = new File(parentFolder.getLocation().toFile().getAbsolutePath());
         IProject project = ReponsitoryContextBridge.getRootProject();
         String defIdxRelativePath = defIdxFolderName + PATH_SEPARATOR + defIdxFileName;
         IFile defIdxFile = project.getFile(defIdxRelativePath);
         if (defIdxFile.exists()) {
           File defIdxFileSource =
               new File(
                   project
                       .getLocation()
                       .makeAbsolute()
                       .append(defIdxFolderName)
                       .append(defIdxFileName)
                       .toFile()
                       .toURI());
           File defIdxFileTarget =
               new File(
                   itemsProjectFolder
                       .getFile(defIdxRelativePath)
                       .getLocation()
                       .toFile()
                       .getAbsolutePath());
           FilesUtils.copyFile(defIdxFileSource, defIdxFileTarget);
         }
         // add report header image & template files
         String reportingBundlePath =
             PluginChecker.getBundlePath("org.talend.dataquality.reporting"); // $NON-NLS-1$
         File imageFolder =
             new File(reportingBundlePath + PATH_SEPARATOR + "images"); // $NON-NLS-1$
         if (imageFolder.exists()) {
           FilesUtils.copyDirectory(imageFolder, itemsFolderDir);
         }
         File templateFolder =
             new File(reportingBundlePath + PATH_SEPARATOR + "reports"); // $NON-NLS-1$
         if (templateFolder.exists() && templateFolder.isDirectory()) {
           FilesUtils.copyDirectory(templateFolder, itemsFolderDir);
         }
       }
     }
   }
 }
 @SuppressWarnings("unchecked")
 public FunctionManager(String type) {
   AbstractFunctionParser parser = null;
   if (JavaUtils.JAVA_PIG_DIRECTORY.equals(type)) {
     // pig map expressionbuilder
     if (GlobalServiceRegister.getDefault().isServiceRegistered(IPigMapService.class)) {
       final IPigMapService service =
           (IPigMapService) GlobalServiceRegister.getDefault().getService(IPigMapService.class);
       parser = service.pigFunctionParser();
       parser.parse();
       talendTypes = parser.getList();
     }
   }
 }
 @Override
 public List<URL> getTalendBeansFolder() throws IOException {
   List<URL> toReturn = new ArrayList<URL>();
   if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerUIService.class)) {
     ILibraryManagerUIService libUiService =
         (ILibraryManagerUIService)
             GlobalServiceRegister.getDefault().getService(ILibraryManagerUIService.class);
     for (IRoutinesProvider routineProvider :
         libUiService.getRoutinesProviders(ECodeLanguage.JAVA)) {
       toReturn.add(routineProvider.getTalendRoutinesFolder());
     }
   }
   return toReturn;
 }
 protected ILaunchConfiguration createLaunchConfiguration() {
   if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
     IRunProcessService processService =
         (IRunProcessService)
             GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
     ITalendProcessJavaProject talendProcessJavaProject =
         processService.getTalendProcessJavaProject();
     if (talendProcessJavaProject != null) {
       IProject project = talendProcessJavaProject.getProject();
       return createLaunchConfiguration(project, goals);
     }
   }
   return null;
 }
  /*
   * (non-Javadoc)
   *
   * @see org.talend.core.model.general.ILibrariesService#getSystemRoutines()
   */
  @Override
  public List<URL> getSystemRoutines() {
    List<URL> toReturn = new ArrayList<URL>();
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerUIService.class)) {
      ILibraryManagerUIService libUiService =
          (ILibraryManagerUIService)
              GlobalServiceRegister.getDefault().getService(ILibraryManagerUIService.class);

      for (IRoutinesProvider routineProvider :
          libUiService.getRoutinesProviders(ECodeLanguage.JAVA)) {
        toReturn.addAll(routineProvider.getSystemRoutines());
      }
    }
    return toReturn;
  }
 @Override
 public void earlyStartup() {
   setupMissingJarLoadingObserver();
   librariesService = LibManagerUiPlugin.getDefault().getLibrariesService();
   libraryManagerService =
       (ILibraryManagerService)
           GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
 }
  /**
   * DOC smallet Comment method "openRoutineEditor".
   *
   * @param item
   * @throws SystemException
   * @throws PartInitException
   */
  public IEditorPart openSQLPatternEditor(SQLPatternItem item, boolean readOnly)
      throws SystemException, PartInitException {
    if (item == null) {
      return null;
    }
    ICodeGeneratorService service =
        (ICodeGeneratorService)
            GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);

    ECodeLanguage lang =
        ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY))
            .getProject()
            .getLanguage();
    ISQLPatternSynchronizer routineSynchronizer = service.getSQLPatternSynchronizer();

    // check if the related editor is open.
    IWorkbenchPage page = getActivePage();

    IEditorReference[] editorParts = page.getEditorReferences();
    String talendEditorID =
        "org.talend.designer.core.ui.editor.StandAloneTalend"
            + lang.getCaseName()
            + "Editor"; //$NON-NLS-1$ //$NON-NLS-2$
    boolean found = false;
    IEditorPart talendEditor = null;
    for (IEditorReference reference : editorParts) {
      IEditorPart editor = reference.getEditor(false);
      if (talendEditorID.equals(editor.getSite().getId())) {
        // TextEditor talendEditor = (TextEditor) editor;
        RepositoryEditorInput editorInput = (RepositoryEditorInput) editor.getEditorInput();
        Item item2 = editorInput.getItem();
        if (item2 != null
            && item2 instanceof SQLPatternItem
            && item2.getProperty().getId().equals(item.getProperty().getId())) {
          if (item2.getProperty().getVersion().equals(item.getProperty().getVersion())) {
            page.bringToTop(editor);
            found = true;
            talendEditor = editor;
            break;
          } else {
            page.closeEditor(editor, false);
          }
        }
      }
    }

    if (!found) {
      routineSynchronizer.syncSQLPattern(item, true);
      IFile file = routineSynchronizer.getSQLPatternFile(item);

      RepositoryEditorInput input = new RepositoryEditorInput(file, item);
      input.setReadOnly(readOnly);
      talendEditor = page.openEditor(input, talendEditorID); // $NON-NLS-1$
    }

    return talendEditor;
  }
  /*
   * (non-Jsdoc)
   *
   * @see org.talend.designer.codegen.AbstractRoutineSynchronizer#doSyncBean(org.talend.core.model.properties.Item,
   * boolean)
   */
  @Override
  protected void doSyncBean(Item item, boolean copyToTemp) throws SystemException {
    if (item instanceof BeanItem) {
      BeanItem beanItem = (BeanItem) item;
      FileOutputStream fos = null;
      try {
        IFile file = getBeanFile(beanItem);
        if (file == null) {
          return;
        }
        if (beanItem.getProperty().getModificationDate() != null) {
          long modificationItemDate = beanItem.getProperty().getModificationDate().getTime();
          long modificationFileDate = file.getModificationStamp();
          if (modificationItemDate <= modificationFileDate) {
            return;
          }
        } else {
          beanItem.getProperty().setModificationDate(new Date());
        }

        if (copyToTemp) {
          String beanContent = new String(beanItem.getContent().getInnerContent());
          // see 14713
          String version = VersionUtils.getVersion();
          if (beanContent.contains("%GENERATED_LICENSE%")) { // $NON-NLS-1$
            IService service =
                GlobalServiceRegister.getDefault().getService(IBrandingService.class);
            if (service instanceof AbstractBrandingService) {
              String routineHeader =
                  ((AbstractBrandingService) service).getRoutineLicenseHeader(version);
              beanContent =
                  beanContent.replace("%GENERATED_LICENSE%", routineHeader); // $NON-NLS-1$
            }
          } // end
          String label = beanItem.getProperty().getLabel();
          if (!label.equals(ITalendSynchronizer.BEAN_TEMPLATE) && beanContent != null) {
            beanContent = beanContent.replaceAll(ITalendSynchronizer.BEAN_TEMPLATE, label);
            File f = file.getLocation().toFile();
            fos = new FileOutputStream(f);
            fos.write(beanContent.getBytes());
            fos.close();
          }
        }
        file.refreshLocal(1, null);
      } catch (CoreException e) {
        throw new SystemException(e);
      } catch (IOException e) {
        throw new SystemException(e);
      } finally {
        try {
          fos.close();
        } catch (Exception e) {
          // ignore me even if i'm null
        }
      }
    }
  }
  /**
   * Gets all demo projects information.
   *
   * @return a list of <code>DemoProjectBean</code>
   */
  public static List<DemoProjectBean> getAllDemoProjects() {
    SAXReader reader = new SAXReader();
    Document doc = null;
    List<DemoProjectBean> demoProjectList = new ArrayList<DemoProjectBean>();
    DemoProjectBean demoProject = null;
    List<File> xmlFilePath = getXMLFilePath();
    for (int t = 0; t < xmlFilePath.size(); t++) {
      try {
        doc = reader.read(xmlFilePath.get(t));
      } catch (DocumentException e) {
        ExceptionHandler.process(e);
        return null;
      }

      Element demoProjectsInfo = doc.getRootElement();

      IBrandingService brandingService =
          (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
      String[] availableLanguages =
          brandingService.getBrandingConfiguration().getAvailableLanguages();

      for (Iterator<DemoProjectBean> i = demoProjectsInfo.elementIterator("project");
          i.hasNext(); ) { // $NON-NLS-1$
        Element demoProjectElement = (Element) i.next();
        demoProject = new DemoProjectBean();
        demoProject.setProjectName(demoProjectElement.attributeValue("name")); // $NON-NLS-1$
        String language = demoProjectElement.attributeValue("language"); // $NON-NLS-1$

        if (!ArrayUtils.contains(availableLanguages, language)) {
          // if the language is not available in current branding, don't display this demo project
          continue;
        }

        demoProject.setLanguage(ECodeLanguage.getCodeLanguage(language));
        String demoProjectFileType =
            demoProjectElement.attributeValue("demoProjectFileType"); // $NON-NLS-1$
        demoProject.setDemoProjectFileType(
            EDemoProjectFileType.getDemoProjectFileTypeName(demoProjectFileType));
        demoProject.setDemoProjectFilePath(
            demoProjectElement.attributeValue("demoFilePath")); // $NON-NLS-1$
        demoProject.setDescriptionFilePath(
            demoProjectElement.attributeValue("descriptionFilePath")); // $NON-NLS-1$
        // get the demo plugin Id
        demoProject.setPluginId(demoProjectElement.attributeValue("pluginId")); // $NON-NLS-1$
        if (demoProject.getProjectName().equals("ESBDEMOS")) {
          if (!PluginChecker.isPluginLoaded("org.talend.repository.services")) {
            continue;
          }
        }
        demoProjectList.add(demoProject);
      }
    }
    return demoProjectList;
  }
  public static List<IComponent> filterNeededComponents(
      Item item, RepositoryNode seletetedNode, ERepositoryObjectType type) {
    if (!GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsService.class)) {
      return Collections.emptyList();
    }
    IComponentsService service =
        (IComponentsService)
            GlobalServiceRegister.getDefault().getService(IComponentsService.class);

    Set<IComponent> components = service.getComponentsFactory().getComponents();
    List<IComponent> neededComponents = new ArrayList<IComponent>();
    List<IComponent> exceptedComponents = new ArrayList<IComponent>();

    for (IComponent component : components) {
      //
      for (RepositoryComponentDndFilterSetting dndFilter : getDndFilterSettings()) {
        IRepositoryComponentDndFilter filter = dndFilter.getFilter();
        if (filter == null) {
          continue;
        }
        String repositoryType = filter.getRepositoryType(item, type);
        if (repositoryType == null) {
          continue;
        }
        if (!exceptedComponents.contains(component)
            && filter.except(item, type, seletetedNode, component, repositoryType)) {
          exceptedComponents.add(component);
        }
        // if have been excepted, so no need add it to needed component
        if (!exceptedComponents.contains(component)
            && !neededComponents.contains(component)
            && filter.valid(item, type, seletetedNode, component, repositoryType)) {
          neededComponents.add(component);
        }
      }
    }
    // remove all excepted components
    neededComponents.removeAll(exceptedComponents);

    return sortFilteredComponnents(item, seletetedNode, type, neededComponents);
  }
  /** yzhang Comment method "updateProblems". */
  private void updateProblems(List<IRepositoryViewObject> routineObjectList, String filePath) {

    IRunProcessService runProcessService = CorePlugin.getDefault().getRunProcessService();
    try {
      ITalendProcessJavaProject talendProcessJavaProject =
          runProcessService.getTalendProcessJavaProject();
      if (talendProcessJavaProject == null) {
        return;
      }
      IProject javaProject = talendProcessJavaProject.getProject();
      IFile file = javaProject.getFile(filePath);
      String fileName = file.getName();

      for (IRepositoryViewObject repositoryObject : routineObjectList) {
        Property property = repositoryObject.getProperty();
        ITalendSynchronizer synchronizer =
            CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
        Item item = property.getItem();
        if (GlobalServiceRegister.getDefault()
            .isServiceRegistered(ICamelDesignerCoreService.class)) {
          ICamelDesignerCoreService service =
              (ICamelDesignerCoreService)
                  GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
          if (service.isInstanceofCamel(item)) {
            synchronizer =
                CorePlugin.getDefault().getCodeGeneratorService().createCamelBeanSynchronizer();
          }
        }
        IFile currentFile = synchronizer.getFile(item);
        if (currentFile != null && fileName.equals(currentFile.getName()) && currentFile.exists()) {
          Problems.addRoutineFile(currentFile, property);
          break;
        }
      }
    } catch (SystemException e) {
      ExceptionHandler.process(e);
    }
  }
 /**
  * DOC sgandon Comment method "updateManualImportedJars".
  *
  * @param importedJars
  */
 private void updateManualImportedJars(AtomicInteger enabledButtonCount, String[] importedJars) {
   for (Entry<ModuleToInstall, Button> moduleAndButton : manualInstallButtonMap.entrySet()) {
     String jarName = moduleAndButton.getKey().getName();
     for (String importedJar : importedJars) {
       if (importedJar.equals(jarName)) { // disable the button
         moduleAndButton.getValue().setEnabled(false);
         enabledButtonCount.decrementAndGet();
       } // else leave the button as it is
     }
   }
   if (enabledButtonCount.get() == 0) {
     close();
     // refresh
     if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
       IDesignerCoreService service =
           (IDesignerCoreService)
               GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
       if (service != null) {
         service.refreshComponentView();
       }
     }
   }
 }
 /** DOC ycbai Comment method "initializeSystemLibs". */
 public void initializeSystemLibs() {
   if (!initialized) {
     ILibraryManagerService libManagerService = null;
     if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
       libManagerService =
           (ILibraryManagerService)
               GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
     }
     for (IConfigurationElement current : configurationElements) {
       String bundleName = current.getContributor().getName();
       Bundle bundle = Platform.getBundle(bundleName);
       Enumeration entryPaths = bundle.getEntryPaths(LIB_FOLDER);
       if (entryPaths == null) {
         continue;
       }
       while (entryPaths.hasMoreElements()) {
         Object entryPath = entryPaths.nextElement();
         if (entryPath != null && entryPath instanceof String) {
           String path = (String) entryPath;
           if (path.endsWith(FileExtensions.JAR_FILE_SUFFIX)) {
             URL entry = bundle.getEntry(path);
             if (entry != null && libManagerService != null) {
               try {
                 URL fileUrl = FileLocator.toFileURL(entry);
                 libManagerService.deploy(fileUrl.toURI());
               } catch (Exception e) {
                 log.warn("Cannot deploy: " + bundleName + path);
                 continue;
               }
             }
           }
         }
       }
     }
     initialized = true;
   }
 }
 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;
 }
  @Override
  protected void doRun() {
    selectObj = getSelectedObject().get(0);

    JobOptionsDialog dialog =
        new JobOptionsDialog(
            getShell(), Messages.JobProcesssDialogTiggerTitle_title, Execution.EMBEDDED);
    dialog.setBlockOnOpen(true);
    int ret = dialog.open();
    if (ret == Dialog.CANCEL) {
      return;
    }

    String jobName = ""; // $NON-NLS-1$
    String jobVersion = ""; // $NON-NLS-1$

    if (selectObj instanceof IRepositoryViewObject) {
      jobName = ((IRepositoryViewObject) selectObj).getProperty().getLabel();
      jobVersion = ((IRepositoryViewObject) selectObj).getProperty().getVersion();
    }
    // check exist
    IValidateService validateService =
        (IValidateService) GlobalServiceRegister.getDefault().getService(IValidateService.class);
    if (validateService != null) {
      boolean result =
          validateService.validateAndAlertObjectExistence(
              IServerObjectRepositoryType.TYPE_ROUTINGRULE, getNewTriggerName(jobName), null);
      if (!result) {
        return;
      }
    }
    //
    WSRoutingRuleE routingRule = createTrigger(jobName, jobVersion, dialog);
    // if the new objectect is opened ,than close it before regenerating
    IRepositoryViewObject toDelete =
        RepositoryResourceUtil.findViewObjectByName(
            IServerObjectRepositoryType.TYPE_ROUTINGRULE, PREFIX + jobName);
    if (toDelete != null) {
      IEditorPart openedEditor = UIUtil.findOpenedEditor(toDelete);
      if (openedEditor != null) {
        UIUtil.closeEditor(openedEditor, false);
      }
      // delete directly
      RepositoryResourceUtil.removeViewObjectPhysically(toDelete, jobVersion);
    }
    AttachToTriggerView(jobName, routingRule);
  }
  @Override
  public List<IComponent> filterNeededComponents(
      Item item, RepositoryNode seletetedNode, ERepositoryObjectType type) {
    List<IComponent> neededComponents = new ArrayList<IComponent>();
    if (!(item instanceof HCatalogConnectionItem)) {
      return neededComponents;
    }
    IComponentsService service =
        (IComponentsService)
            GlobalServiceRegister.getDefault().getService(IComponentsService.class);
    Set<IComponent> components = service.getComponentsFactory().getComponents();
    for (IComponent component : components) {
      if (isValid(item, type, seletetedNode, component, HCATALOG)
          && !neededComponents.contains(component)) {
        neededComponents.add(component);
      }
    }

    return neededComponents;
  }
Beispiel #24
0
    @Override
    public Map<ModuleNeeded, File> getFilesToShare(IProgressMonitor monitor) {
      Map<ModuleNeeded, File> files = new HashMap<ModuleNeeded, File>();
      SubMonitor mainSubMonitor = SubMonitor.convert(monitor, 1);
      mainSubMonitor.setTaskName(Messages.getString("ShareLibsJob.getFilesToShare")); // $NON-NLS-1$
      final List<ModuleNeeded> modulesNeeded =
          new ArrayList<ModuleNeeded>(ModulesNeededProvider.getModulesNeeded());
      ILibraryManagerService librariesService =
          (ILibraryManagerService)
              GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
      Set<String> filePaths = new HashSet<String>();
      for (ModuleNeeded module : modulesNeeded) {
        if (monitor.isCanceled()) {
          return null;
        }

        // only deploy libraries with group id org.talend.libraries
        MavenArtifact parseMvnUrl = MavenUrlHelper.parseMvnUrl(module.getMavenUri());
        if (parseMvnUrl == null
            || !MavenConstants.DEFAULT_LIB_GROUP_ID.equals(parseMvnUrl.getGroupId())) {
          continue;
        }

        final String jarPathFromMaven =
            librariesService.getJarPathFromMaven(module.getMavenUriSnapshot());
        if (jarPathFromMaven == null) {
          continue;
        }
        File jarFile = new File(jarPathFromMaven);
        if (jarFile.exists()) {
          if (!filePaths.contains(jarPathFromMaven)) {
            files.put(module, jarFile);
          }
          filePaths.add(jarPathFromMaven);
        }
      }
      mainSubMonitor.worked(1);
      return files;
    }
  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;
  }
  @Override
  protected Control createDialogArea(Composite parent) {
    // set the whole page white
    parent.setBackground(new Color(null, new RGB(255, 255, 255)));
    parent.setBackgroundMode(SWT.INHERIT_FORCE);

    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);

    Composite top = new Composite(container, SWT.NONE);
    top.setLayout(new GridLayout());
    top.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    Label label = new Label(top, SWT.NONE);
    label.setText(REGISTER_TITLE);
    label.setFont(TITLE_FONT);
    label.setForeground(YELLOW_GREEN_COLOR);

    Composite centerComposite = new Composite(container, SWT.NONE);
    centerComposite.setLayout(new GridLayout()); // top.setLayoutData(new
    // GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    centerComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));

    // createSpacer(centerComposite, SWT.NONE);

    IBrandingService brandingService =
        (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    String thanks1 =
        Messages.getString("RegisterWizardPage.legalthanks1", brandingService.getCorporationName());
    String thanks2 =
        Messages.getString("RegisterWizardPage.legalthanks2", brandingService.getCorporationName());
    Font font2 = new Font(null, "Arial", 10, SWT.BOLD);

    Composite c1 = new Composite(centerComposite, SWT.NONE);
    c1.setLayout(new GridLayout());
    c1.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    Label label1 = new Label(c1, SWT.NONE);
    label1.setText(thanks1);
    label1.setFont(font2);

    Composite c2 = new Composite(centerComposite, SWT.NONE);
    c2.setLayout(new GridLayout());
    c2.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    Label label2 = new Label(c2, SWT.NONE);
    label2.setText(thanks2);
    label2.setFont(font2);

    // createSpacer(centerComposite, SWT.NONE);
    createSpacer(centerComposite, SWT.NONE);

    String string =
        Messages.getString("RegisterWizardPage.legalconfirm", brandingService.getCorporationName());
    Composite c3 = new Composite(centerComposite, SWT.NONE);
    c3.setLayout(new GridLayout());
    c3.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    Label label3 = new Label(c3, SWT.NONE);
    label3.setText(string);
    // label3.setFont(font2);
    // createLegalInfos(centerComposite, 1, string2);

    createSpacer(centerComposite, SWT.NONE);

    Composite bottomComposite = new Composite(container, SWT.NONE);
    bottomComposite.setLayout(new GridLayout(3, true));

    bottomComposite.setLayoutData(new GridData());

    new Label(bottomComposite, SWT.NONE);
    // label3.setLayoutData(new GridData());

    new ImageCanvas(bottomComposite, ImageProvider.getImageDesc(ERepositoryImages.REGISTER_ICO));

    return container;
  }
  /**
   * DOC nrousseau Comment method "addTDMDependencies".
   *
   * @param items
   * @param itemsFolder
   */
  private void addTDMDependencies(IFolder itemsFolder, List<Item> items) {
    ITransformService tdmService = null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITransformService.class)) {
      tdmService =
          (ITransformService)
              GlobalServiceRegister.getDefault().getService(ITransformService.class);
    }
    try {
      // add __tdm dependencies
      ExportFileResource resouece = new ExportFileResource();
      BuildExportManager.getInstance().exportDependencies(resouece, processItem);
      if (!resouece.getAllResources().isEmpty()) {
        final Iterator<String> relativepath = resouece.getRelativePathList().iterator();
        while (relativepath.hasNext()) {
          String relativePath = relativepath.next();
          Set<URL> sources = resouece.getResourcesByRelativePath(relativePath);
          for (URL sourceUrl : sources) {
            File currentResource =
                new File(
                    org.talend.commons.utils.io.FilesUtils.getFileRealPath(sourceUrl.getPath()));
            if (currentResource.exists()) {
              // the __tdm will be out of items folder, same level for items
              IFolder targetFolder = ((IFolder) itemsFolder.getParent()).getFolder(relativePath);
              if (!targetFolder.exists()) {
                targetFolder.create(true, true, new NullProgressMonitor());
              }
              FilesUtils.copyFile(
                  currentResource,
                  new File(
                      targetFolder.getLocation().toPortableString()
                          + File.separator
                          + currentResource.getName()));
            }
          }
        }
      }

      itemsFolder.refreshLocal(IResource.DEPTH_INFINITE, null);

      // add .settings/com.oaklandsw.base.projectProps for tdm, it should be added via
      // ExportItemUtil, here just
      // make sure to export again.
      for (Item item : items) {
        if (tdmService != null && tdmService.isTransformItem(item)) {
          String itemProjectFolder = getProject(item).getTechnicalLabel();
          if (isProjectNameLowerCase()) { // should be same as ExportItemUtil.getProjectOutputPath
            itemProjectFolder = itemProjectFolder.toLowerCase();
          }
          IPath targetSettingPath =
              new Path(itemProjectFolder).append(RepositoryConstants.SETTING_DIRECTORY);
          IFolder targetSettingsFolder =
              talendProcessJavaProject.createSubFolder(
                  null, itemsFolder, targetSettingPath.toString());

          IProject sourceProject = getCorrespondingProjectRootFolder(item);

          if (sourceProject.exists()) {
            IFile targetTdmPropsFile = targetSettingsFolder.getFile(FileConstants.TDM_PROPS);
            IFile sourceTdmPropsFile =
                sourceProject
                    .getFolder(RepositoryConstants.SETTING_DIRECTORY)
                    .getFile(FileConstants.TDM_PROPS);

            // if have existed, no need copy again.
            if (sourceTdmPropsFile.exists() && !targetTdmPropsFile.exists()) {
              sourceTdmPropsFile.copy(targetTdmPropsFile.getFullPath(), true, null);
            }
          }
          break; // only deal with one time.
        }
      }
    } catch (Exception e) {
      // don't block all the export if got exception here
      ExceptionHandler.process(e);
    }
  }
/**
 * DOC smallet class global comment. Detailled comment <br>
 * $Id$
 */
public class JavaLibrariesService extends AbstractLibrariesService {

  private static Logger log = Logger.getLogger(JavaLibrariesService.class);

  private static ILibraryManagerService repositoryBundleService =
      (ILibraryManagerService)
          GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);

  public static final String SOURCE_JAVA_ROUTINES_FOLDER = "routines"; // $NON-NLS-1$

  public static final String SOURCE_JAVA_PIGUDF_FOLDER = "pigudf"; // $NON-NLS-1$

  public static final String SOURCE_JAVA_BEANS_FOLDER = "beans"; // $NON-NLS-1$

  private static boolean isLibSynchronized;

  @Override
  public URL getRoutineTemplate() {
    return Platform.getBundle(LibrariesManagerUtils.BUNDLE_DI)
        .getEntry(
            "resources/java/"
                + SOURCE_JAVA_ROUTINES_FOLDER
                + "/__TEMPLATE__.java"); //$NON-NLS-1$ //$NON-NLS-2$
  }

  @Override
  public URL getPigudfTemplate(PigTemplate template) {
    Bundle bundle = Platform.getBundle(LibrariesManagerUtils.BUNDLE_DI);
    return bundle.getEntry(
        "templates/"
            + SOURCE_JAVA_PIGUDF_FOLDER
            + "/"
            + template.getFileName()
            + ".java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
  }

  @Override
  public URL getBeanTemplate() {
    return Platform.getBundle(LibrariesManagerUtils.BUNDLE_DI)
        .getEntry(
            "resources/java/"
                + SOURCE_JAVA_BEANS_FOLDER
                + "/__BEAN_TEMPLATE__.java"); //$NON-NLS-1$ //$NON-NLS-2$
  }

  /*
   * (non-Javadoc)
   *
   * @see org.talend.core.model.general.ILibrariesService#getSqlPatternTemplate()
   */
  @Override
  public URL getSqlPatternTemplate() {
    return Platform.getBundle(LibrariesManagerUtils.BUNDLE_DI)
        .getEntry(
            "resources/java/"
                + SOURCE_SQLPATTERN_FOLDER
                + "/__TEMPLATE__"
                + TEMPLATE_SUFFIX); //$NON-NLS-1$ //$NON-NLS-2$
  }

  /*
   * (non-Javadoc)
   *
   * @see org.talend.core.model.general.ILibrariesService#getSystemRoutines()
   */
  @Override
  public List<URL> getSystemRoutines() {
    List<URL> toReturn = new ArrayList<URL>();
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerUIService.class)) {
      ILibraryManagerUIService libUiService =
          (ILibraryManagerUIService)
              GlobalServiceRegister.getDefault().getService(ILibraryManagerUIService.class);

      for (IRoutinesProvider routineProvider :
          libUiService.getRoutinesProviders(ECodeLanguage.JAVA)) {
        toReturn.addAll(routineProvider.getSystemRoutines());
      }
    }
    return toReturn;
  }

  @Override
  public List<URL> getSystemSQLPatterns() {
    return FilesUtils.getFilesFromFolder(
        Platform.getBundle(LibrariesManagerUtils.BUNDLE_DI),
        "resources/java/" + SOURCE_SQLPATTERN_FOLDER, // $NON-NLS-1$
        SQLPATTERN_FILE_SUFFIX,
        false,
        true);
  }

  /*
   * (non-Javadoc)
   *
   * @see org.talend.core.model.general.ILibrariesService#getTalendRoutines()
   */
  @Override
  public List<URL> getTalendRoutinesFolder() throws IOException {
    List<URL> toReturn = new ArrayList<URL>();
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerUIService.class)) {
      ILibraryManagerUIService libUiService =
          (ILibraryManagerUIService)
              GlobalServiceRegister.getDefault().getService(ILibraryManagerUIService.class);
      for (IRoutinesProvider routineProvider :
          libUiService.getRoutinesProviders(ECodeLanguage.JAVA)) {
        toReturn.add(routineProvider.getTalendRoutinesFolder());
      }
    }

    return toReturn;
  }

  @Override
  public List<URL> getTalendBeansFolder() throws IOException {
    List<URL> toReturn = new ArrayList<URL>();
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerUIService.class)) {
      ILibraryManagerUIService libUiService =
          (ILibraryManagerUIService)
              GlobalServiceRegister.getDefault().getService(ILibraryManagerUIService.class);
      for (IRoutinesProvider routineProvider :
          libUiService.getRoutinesProviders(ECodeLanguage.JAVA)) {
        toReturn.add(routineProvider.getTalendRoutinesFolder());
      }
    }
    return toReturn;
  }

  @Override
  public List<URL> getTalendRoutines() {
    List<URL> toReturn = new ArrayList<URL>();
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerUIService.class)) {
      ILibraryManagerUIService libUiService =
          (ILibraryManagerUIService)
              GlobalServiceRegister.getDefault().getService(ILibraryManagerUIService.class);
      for (IRoutinesProvider routineProvider :
          libUiService.getRoutinesProviders(ECodeLanguage.JAVA)) {
        toReturn.addAll(routineProvider.getTalendRoutines());
      }
    }

    return toReturn;
  }

  @Override
  public void checkInstalledLibraries() {
    Set<String> existLibraries = repositoryBundleService.list();
    List<String> modulesNeededNames = ModulesNeededProvider.getModulesNeededNames();
    ModulesNeededProvider.getUnUsedModules().clear();
    for (String library : existLibraries) {
      if (!modulesNeededNames.contains(library)) {
        ModulesNeededProvider.userAddUnusedModules("Unknown", library); // $NON-NLS-1$
      }
    }
  }

  @Override
  public void syncLibrariesFromApp(IProgressMonitor... monitorWrap) {
    // do nothing
  }

  private File getStorageDirectory() {
    String librariesPath = LibrariesManagerUtils.getLibrariesPath(ECodeLanguage.JAVA);
    File storageDir = new File(librariesPath);
    return storageDir;
  }

  @Override
  public void syncLibraries(IProgressMonitor... monitorWrap) {
    // TODO system routine libraries seems no use ,need to check more...
    // deploy system routine libraries
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerUIService.class)) {
      ILibraryManagerUIService libUiService =
          (ILibraryManagerUIService)
              GlobalServiceRegister.getDefault().getService(ILibraryManagerUIService.class);
      libUiService.initializeSystemLibs();
    }

    if (TalendCacheUtils.cleanComponentCache()) {
      repositoryBundleService.clearCache();
    }
    // Add a new system file, if exists, means all components libs are already setup, so no need to
    // do again.
    // if clean the component cache, it will automatically recheck all libs still.
    if (!repositoryBundleService.isInitialized()) {
      // 2. Components libraries
      if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsService.class)) {
        repositoryBundleService.deployComponentsLibs(monitorWrap);
        repositoryBundleService.setInitialized();
      }
    }

    checkInstalledLibraries();

    // clean the temp library of job needed in .java\lib
    cleanLibs();

    log.debug(Messages.getString("JavaLibrariesService.synchronization")); // $NON-NLS-1$
    isLibSynchronized = true;
  }

  protected void updateProjectLib(String libName) {}

  /*
   * (non-Javadoc)
   *
   * @see org.talend.core.model.general.ILibrariesService#isLibSynchronized()
   */
  @Override
  public boolean isLibSynchronized() {
    return this.isLibSynchronized;
  }

  /*
   * (non-Javadoc)
   *
   * @see org.talend.core.model.general.ILibrariesService#getPerlLibrariesPath()
   */
  @Override
  public String getPerlLibrariesPath() {
    // TODO Auto-generated method stub
    return null;
  }

  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.core.model.general.ILibrariesService#syncLibrariesFromLibs(org.eclipse.core.runtime.IProgressMonitor
   * [])
   */
  @Override
  public void syncLibrariesFromLibs(IProgressMonitor... monitorWrap) {
    // TODO sync project/lib will be done in migration
    // for feature 12877
    // if (PluginChecker.isSVNProviderPluginLoaded()) {
    // String path = new Path(Platform.getInstanceLocation().getURL().getPath()).toFile().getPath();
    // String projectLabel = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
    // path = path + File.separatorChar + projectLabel + File.separatorChar
    // + ERepositoryObjectType.getFolderName(ERepositoryObjectType.LIBS);
    // File libsTargetFile = new File(path);
    // repositoryBundleService.deploy(libsTargetFile.toURI(), monitorWrap);
    // }
  }
}
  /*
   * (non-Javadoc)
   *
   * @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
   * org.eclipse.jface.viewers.IStructuredSelection)
   */
  @Override
  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;
      Object property = node.getProperties(EProperties.CONTENT_TYPE);
      switch (node.getType()) {
        case REPOSITORY_ELEMENT:
        case STABLE_SYSTEM_FOLDER:
          canWork = false;
          break;
        case SYSTEM_FOLDER:
          if (ERepositoryObjectType.GENERATED.equals(property)
              || ERepositoryObjectType.JOBS.equals(property)
              || ERepositoryObjectType.JOBLETS.equals(property)
              || ERepositoryObjectType.SQLPATTERNS.equals(property)
              || ERepositoryObjectType.REFERENCED_PROJECTS.equals(property)
              || ERepositoryObjectType.SVN_ROOT.equals(property)) {
            canWork = false;
          } else if (property != null
              && GlobalServiceRegister.getDefault()
                  .isServiceRegistered(ICamelDesignerCoreService.class)) {
            ICamelDesignerCoreService camelService =
                (ICamelDesignerCoreService)
                    GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
            if (property.equals(camelService.getRouteDocsType())) {
              canWork = false;
            }
          }
          break;
        case SIMPLE_FOLDER:
          if (ERepositoryObjectType.JOB_DOC.equals(property)
              || ERepositoryObjectType.JOBLET_DOC.equals(property)
              || (ERepositoryObjectType.SQLPATTERNS.equals(property)
                  && !isUnderUserDefined(node))) {
            canWork = false;
          } else if (property != null
              && GlobalServiceRegister.getDefault()
                  .isServiceRegistered(ICamelDesignerCoreService.class)) {
            ICamelDesignerCoreService camelService =
                (ICamelDesignerCoreService)
                    GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
            if (property.equals(camelService.getRouteDocType())) {
              canWork = false;
            }
          }
          if (node.getObject().isDeleted()) {
            canWork = false;
          }
          break;
        default:
          // Nothing to do
      }

      if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) {
        canWork = false;
      }
    }
    setEnabled(canWork);
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
   */
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);

    GridLayout layout = new GridLayout(2, false);
    container.setLayout(layout);

    // Name
    Label nameLab = new Label(container, SWT.NONE);
    nameLab.setText(Messages.getString("NewProjectWizardPage.name")); // $NON-NLS-1$

    nameText = new Text(container, SWT.BORDER);
    nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // TechnicalName (for information only)
    Label technicalNameLab = new Label(container, SWT.NONE);
    technicalNameLab.setText(
        Messages.getString("NewProjectWizardPage.technicalName")); // $NON-NLS-1$

    technicalNameText = new Text(container, SWT.BORDER);
    technicalNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    technicalNameText.setEnabled(false);

    // Description
    Label descriptionLab = new Label(container, SWT.NONE);
    descriptionLab.setText(Messages.getString("NewProjectWizardPage.comment")); // $NON-NLS-1$
    descriptionLab.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

    descriptionText = new Text(container, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 60;
    descriptionText.setLayoutData(data);

    // Language
    Label languageLab = new Label(container, SWT.NONE);
    languageLab.setText(Messages.getString("NewProjectWizardPage.language")); // $NON-NLS-1$
    languageLab.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

    Composite radioContainer = new Composite(container, SWT.NONE);
    radioContainer.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL + GridData.VERTICAL_ALIGN_BEGINNING));
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginHeight = 0;
    radioContainer.setLayout(gridLayout);

    languageJavaRadio = new Button(radioContainer, SWT.RADIO);
    languageJavaRadio.setText(ECodeLanguage.JAVA.getName());
    languageJavaRadio.setSelection(true);

    languagePerlRadio = new Button(radioContainer, SWT.RADIO);
    languagePerlRadio.setText(ECodeLanguage.PERL.getName() + " (deprecated)");

    IBrandingService brandingService =
        (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    String[] availableLanguages =
        brandingService.getBrandingConfiguration().getAvailableLanguages();
    if (availableLanguages.length != 2) {
      if (ArrayUtils.contains(availableLanguages, ECodeLanguage.JAVA.getName())) {
        languagePerlRadio.setVisible(false);
        languageJavaRadio.setVisible(false);
        languageJavaRadio.setSelection(true);
        languageLab.setVisible(false);
      }
      if (ArrayUtils.contains(availableLanguages, ECodeLanguage.PERL.getName())) {
        languagePerlRadio.setSelection(true);
        languageJavaRadio.setVisible(false);
        languageJavaRadio.setVisible(false);
        languageLab.setVisible(false);
      }
    }

    // languageCombo = new Combo(container, SWT.BORDER | SWT.READ_ONLY);
    // languageCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // languageCombo.setItems(new String[] { ECodeLanguage.PERL.getName(),
    // ECodeLanguage.JAVA.getName() });
    // languageCombo.select(0);

    setControl(container);
    addListeners();
    setPageComplete(false);
  }