コード例 #1
0
  @Override
  public void refresh(IElementParameter param, boolean check) {
    CCombo combo = (CCombo) hashCurControls.get(param.getName());
    if (combo == null || combo.isDisposed()) {
      return;
    }
    updateData();

    String[] curNameList = param.getListItemsDisplayName();

    Object value = param.getValue();

    combo.setItems(curNameList);
    if (value instanceof String) {
      combo.setText(TalendTextUtils.removeQuotes((String) value));
    }

    if (param.isContextMode()) {
      Button buttonEdit = (Button) hashCurControls.get(param.getName() + BUTTON_EDIT);
      combo.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
      combo.setEnabled(false);
      buttonEdit.setEnabled(false);
    }
  }
コード例 #2
0
 @Override
 public void refresh(IElementParameter param, boolean checkErrorsWhenViewRefreshed) {
   Text text = (Text) hashCurControls.get(param.getName());
   if (text == null || text.isDisposed()) {
     return;
   }
   Object value = param.getValue();
   if (value == null) {
     text.setText(""); // $NON-NLS-1$
   } else {
     if (!value.equals(text.getText())) {
       text.setText((String) value);
     }
   }
   if (checkErrorsWhenViewRefreshed) {
     checkErrorsForPropertiesOnly(text);
   }
 }
コード例 #3
0
  public Command createCommand(SelectionEvent selectionEvent) {
    Set<String> elementsName;
    Control ctrl;
    elementsName = hashCurControls.keySet();
    for (String name : elementsName) {
      Object o = hashCurControls.get(name);
      if (o instanceof Control) {
        ctrl = (Control) o;
        if (ctrl == null) {
          hashCurControls.remove(name);
          return null;
        }

        if (ctrl.equals(selectionEvent.getSource()) && ctrl instanceof CCombo) {
          boolean isDisposed = ((CCombo) ctrl).isDisposed();
          if (!isDisposed && (!elem.getPropertyValue(name).equals(((CCombo) ctrl).getText()))) {

            String value = new String(""); // $NON-NLS-1$
            for (int i = 0; i < elem.getElementParameters().size(); i++) {
              IElementParameter param = elem.getElementParameters().get(i);
              if (param.getName().equals(name)) {
                for (int j = 0; j < param.getListItemsValue().length; j++) {
                  if (((CCombo) ctrl).getText().equals(param.getListItemsDisplayName()[j])) {
                    value = (String) param.getListItemsValue()[j];
                  }
                }
              }
            }
            if (value.equals(elem.getPropertyValue(name))) { // same
              // value so
              // no
              // need to do
              // anything
              return null;
            }
            CorePlugin.getDefault().getLibrariesService().resetModulesNeeded();
            return new PropertyChangeCommand(elem, name, value);
          }
        }
      }
    }
    return null;
  }
      public void logCompSetting() {
        if (log4jEnabled) {

          stringBuffer.append(TEXT_10);
          stringBuffer.append(var("log4jParamters"));
          stringBuffer.append(TEXT_11);
          stringBuffer.append(TEXT_12);
          stringBuffer.append(var("log4jParamters"));
          stringBuffer.append(TEXT_13);

          java.util.Set<org.talend.core.model.process.EParameterFieldType> ignoredParamsTypes =
              new java.util.HashSet<org.talend.core.model.process.EParameterFieldType>();
          ignoredParamsTypes.addAll(
              java.util.Arrays.asList(
                  org.talend.core.model.process.EParameterFieldType.SCHEMA_TYPE,
                  org.talend.core.model.process.EParameterFieldType.LABEL,
                  org.talend.core.model.process.EParameterFieldType.EXTERNAL,
                  org.talend.core.model.process.EParameterFieldType.MAPPING_TYPE,
                  org.talend.core.model.process.EParameterFieldType.IMAGE,
                  org.talend.core.model.process.EParameterFieldType.TNS_EDITOR,
                  org.talend.core.model.process.EParameterFieldType.WSDL2JAVA,
                  org.talend.core.model.process.EParameterFieldType.GENERATEGRAMMARCONTROLLER,
                  org.talend.core.model.process.EParameterFieldType
                      .GENERATE_SURVIVORSHIP_RULES_CONTROLLER,
                  org.talend.core.model.process.EParameterFieldType.REFRESH_REPORTS,
                  org.talend.core.model.process.EParameterFieldType.BROWSE_REPORTS,
                  org.talend.core.model.process.EParameterFieldType.PALO_DIM_SELECTION,
                  org.talend.core.model.process.EParameterFieldType.GUESS_SCHEMA,
                  org.talend.core.model.process.EParameterFieldType.MATCH_RULE_IMEX_CONTROLLER,
                  org.talend.core.model.process.EParameterFieldType.MEMO_PERL,
                  org.talend.core.model.process.EParameterFieldType.DBTYPE_LIST,
                  org.talend.core.model.process.EParameterFieldType.VERSION,
                  org.talend.core.model.process.EParameterFieldType.TECHNICAL,
                  org.talend.core.model.process.EParameterFieldType.ICON_SELECTION,
                  org.talend.core.model.process.EParameterFieldType.JAVA_COMMAND,
                  org.talend.core.model.process.EParameterFieldType.TREE_TABLE,
                  org.talend.core.model.process.EParameterFieldType.VALIDATION_RULE_TYPE,
                  org.talend.core.model.process.EParameterFieldType.DCSCHEMA,
                  org.talend.core.model.process.EParameterFieldType.SURVIVOR_RELATION,
                  org.talend.core.model.process.EParameterFieldType.REST_RESPONSE_SCHEMA_TYPE));
          for (org.talend.core.model.process.IElementParameter ep :
              org.talend.core.model.utils.NodeUtil.getDisplayedParameters(node)) {
            if (!ep.isLog4JEnabled() || ignoredParamsTypes.contains(ep.getFieldType())) {
              continue;
            }
            String name = ep.getName();
            if (org.talend.core.model.process.EParameterFieldType.PASSWORD.equals(
                ep.getFieldType())) {
              String epName = "__" + name + "__";
              String password = "";
              if (org.talend.core.model.process.ElementParameterParser.canEncrypt(node, epName)) {
                password =
                    org.talend.core.model.process.ElementParameterParser.getEncryptedValue(
                        node, epName);
              } else {
                String passwordValue =
                    org.talend.core.model.process.ElementParameterParser.getValue(node, epName);
                if (passwordValue == null
                    || "".equals(passwordValue.trim())) { // for the value which empty
                  passwordValue = "\"\"";
                }
                password =
                    "******" + passwordValue + ")";
              }

              stringBuffer.append(TEXT_14);
              stringBuffer.append(var("log4jParamters"));
              stringBuffer.append(TEXT_15);
              stringBuffer.append(name);
              stringBuffer.append(TEXT_16);
              stringBuffer.append(password);
              stringBuffer.append(TEXT_17);

            } else {
              String value =
                  org.talend.core.model.utils.NodeUtil.getNormalizeParameterValue(node, ep);

              stringBuffer.append(TEXT_18);
              stringBuffer.append(var("log4jParamters"));
              stringBuffer.append(TEXT_19);
              stringBuffer.append(name);
              stringBuffer.append(TEXT_20);
              stringBuffer.append(value);
              stringBuffer.append(TEXT_21);
            }

            stringBuffer.append(TEXT_22);
            stringBuffer.append(var("log4jParamters"));
            stringBuffer.append(TEXT_23);
          }
        }
        debug(var("log4jParamters"));
      }
  public static ElementParameterType getElemeterParameterType(IElementParameter param) {
    if (param == null) {
      return null;
    }
    ElementParameterType targetPramType = TalendFileFactory.eINSTANCE.createElementParameterType();
    if (param.getParentParameter() != null) {
      targetPramType.setName(
          param.getParentParameter().getName() + ":" + param.getName()); // $NON-NLS-1$
    } else {
      targetPramType.setName(param.getName());
    }
    targetPramType.setField(param.getFieldType().getName());
    targetPramType.setContextMode(param.isContextMode());
    Object value = param.getValue();
    if (param.getFieldType().equals(EParameterFieldType.TABLE) && value != null) {
      List<Map<String, Object>> tableValues = (List<Map<String, Object>>) value;
      for (Map<String, Object> currentLine : tableValues) {
        for (int i = 0; i < param.getListItemsDisplayCodeName().length; i++) {
          ElementValueType elementValue = TalendFileFactory.eINSTANCE.createElementValueType();
          elementValue.setElementRef(param.getListItemsDisplayCodeName()[i]);
          Object o = currentLine.get(param.getListItemsDisplayCodeName()[i]);

          IElementParameter tmpParam = null;
          Object[] listItemsValue = param.getListItemsValue();
          if (listItemsValue.length > i) {
            tmpParam = (IElementParameter) listItemsValue[i];
          }
          String strValue = ""; // $NON-NLS-1$
          if (o instanceof Integer && tmpParam != null) {
            if (tmpParam.getListItemsValue().length == 0) {
              strValue = ""; // $NON-NLS-1$
            } else {
              strValue = (String) tmpParam.getListItemsValue()[(Integer) o];
            }
          } else {
            if (o instanceof String) {
              strValue = (String) o;
            } else {
              if (o instanceof Boolean) {
                strValue = ((Boolean) o).toString();
              }
            }
          }
          if (tmpParam != null && tmpParam.getFieldType().equals(EParameterFieldType.PASSWORD)) {
            elementValue.setValue(strValue, true);
          } else {
            elementValue.setValue(strValue);
          }
          //
          Object object =
              currentLine.get(param.getListItemsDisplayCodeName()[i] + IEbcdicConstant.REF_TYPE);
          if (object != null) {
            elementValue.setType((String) object);
          }
          targetPramType.getElementValue().add(elementValue);
        }
      }
    } else {
      if (value == null) {
        targetPramType.setValue(""); // $NON-NLS-1$
      } else {
        if (value instanceof Boolean) {
          targetPramType.setValue(((Boolean) value).toString());
        } else {
          if (value instanceof String) {
            targetPramType.setRawValue(value.toString());
          }
        }
      }
    }

    return targetPramType;
  }
  /**
   * load the Element's parameters to EMF Model
   *
   * @param elemParam
   * @param paType
   */
  public static void loadElementParameters(
      Element elemParam, ParametersType paType, String repParamName) {
    if (paType == null || elemParam == null) {
      return;
    }
    EList listParamType = paType.getElementParameter();
    ElementParameterType repositoryParam = null;
    if (repParamName != null && !repParamName.equals("")) {
      repositoryParam = findElementParameterType(paType, repParamName);
    } else {
      repositoryParam =
          findElementParameterType(
              paType,
              EParameterName.PROPERTY_TYPE.getName()
                  + ":"
                  + EParameterName.PROPERTY_TYPE.getName());
    }

    IElementParameter statsDBType = null;
    IElementParameter implicitDBType = null;
    IElementParameter statsDBVersion = null;
    IElementParameter implicitDBVersion = null;

    for (int j = 0; j < listParamType.size(); j++) {
      ElementParameterType pType = (ElementParameterType) listParamType.get(j);
      if (pType != null) {
        String pTypeName = pType.getName();
        if (pTypeName != null && !"".equals(pTypeName)) {
          IElementParameter param = elemParam.getElementParameter(pTypeName);
          if (pTypeName.equals("DB_TYPE")) { // $NON-NLS-1$
            statsDBType = param;
          } else if (pTypeName.equals("DB_VERSION")) { // $NON-NLS-1$
            statsDBVersion = param;
          } else if (pTypeName.equals("DB_TYPE_IMPLICIT_CONTEXT")) { // $NON-NLS-1$
            implicitDBType = param;
          } else if (pTypeName.equals("DB_VERSION_IMPLICIT_CONTEXT")) { // $NON-NLS-1$
            implicitDBVersion = param;
          }
          if (param != null) {
            String name = param.getName();
            param.setContextMode(pType.isContextMode());
            if (param.isReadOnly()
                && !(EParameterName.UNIQUE_NAME.getName().equals(name)
                    || EParameterName.VERSION.getName().equals(name))) {
              continue; // if the parameter is read only, don't load
              // it (this will prevent to overwrite the
              // value)
            }
            String value = null;
            if ("STATANDLOG_USE_PROJECT_SETTINGS".equals(name) // $NON-NLS-1$
                || "IMPLICITCONTEXT_USE_PROJECT_SETTINGS".equals(name)) { // $NON-NLS-1$
              Object value2 = param.getValue();
              if (value2 != null) {
                value = value2.toString();
              }
            } else {
              value = pType.getValue();
            }
            if (param.getFieldType().equals(EParameterFieldType.CHECK)
                || param.getFieldType().equals(EParameterFieldType.RADIO)) {
              if (Boolean.FALSE.toString().equalsIgnoreCase(value)
                  || Boolean.TRUE.toString().equalsIgnoreCase(value)
                  || !pType.isContextMode()) {
                Boolean boolean1 = new Boolean(value);
                elemParam.setPropertyValue(pTypeName, boolean1);
              } else {
                elemParam.setPropertyValue(pTypeName, value);
              }
              // if (EParameterName.ACTIVATE.getName().equals(param.getName())) {
              // if ((elemParam instanceof Node) && !boolean1) {
              // ((Node) elemParam).setDummy(!boolean1);
              // }
              // }
            } else if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST)) {
              boolean valueSet = false;
              if (!ArrayUtils.contains(param.getListItemsValue(), value)) {
                if (ArrayUtils.contains(param.getListItemsDisplayName(), value)) {
                  valueSet = true;
                  int index = ArrayUtils.indexOf(param.getListItemsDisplayName(), value);
                  if (index > -1) {
                    elemParam.setPropertyValue(pTypeName, param.getListItemsValue()[index]);
                  }
                } else if (value.equals("")
                    && name != null
                    && (name.equals("LOAD_NEW_VARIABLE") || name.equals("NOT_LOAD_OLD_VARIABLE"))) {
                  valueSet = true;
                  elemParam.setPropertyValue(pTypeName, param.getListItemsValue()[1]);
                }
              }
              if (!valueSet) {
                elemParam.setPropertyValue(pTypeName, value);
              }
            } else if (param.getFieldType().equals(EParameterFieldType.TABLE)) {
              List<Map<String, Object>> tableValues = new ArrayList<Map<String, Object>>();
              String[] codeList = param.getListItemsDisplayCodeName();
              Map<String, Object> lineValues = null;
              for (ElementValueType elementValue :
                  (List<ElementValueType>) pType.getElementValue()) {
                boolean found = false;
                int length = codeList.length;
                if (length > 0) {
                  for (int i = 0; i < length && !found; i++) {
                    if (codeList[i].equals(elementValue.getElementRef())) {
                      found = true;
                    }
                  }
                }
                IElementParameter tmpParam = null;
                for (Object o : param.getListItemsValue()) {
                  if (o instanceof IElementParameter) {
                    IElementParameter tableParam = (IElementParameter) o;
                    if (tableParam.getName().equals(elementValue.getElementRef())) {
                      tmpParam = tableParam;
                      break;
                    }
                  }
                }
                if (found) {
                  if ((lineValues == null)
                      || (lineValues.get(elementValue.getElementRef()) != null)) {
                    lineValues = new HashMap<String, Object>();
                    tableValues.add(lineValues);
                  }
                  String elemValue = elementValue.getValue();
                  if (tmpParam != null
                      && EParameterFieldType.PASSWORD.equals(tmpParam.getFieldType())) {
                    elemValue = elementValue.getRawValue();
                  }
                  lineValues.put(elementValue.getElementRef(), elemValue);
                  if (elementValue.getType() != null) {
                    lineValues.put(
                        elementValue.getElementRef() + IEbcdicConstant.REF_TYPE,
                        elementValue.getType());
                  }
                }
              }
              elemParam.setPropertyValue(pTypeName, tableValues);
            } else if (param.getFieldType().equals(EParameterFieldType.PASSWORD)) {
              param.setValue(pType.getRawValue());
            } else if (param.getFieldType().equals(EParameterFieldType.ENCODING_TYPE)) {
              // fix for bug 2193
              boolean setToCustom = false;
              if (EmfComponent.REPOSITORY.equals(
                      elemParam.getPropertyValue(EParameterName.PROPERTY_TYPE.getName()))
                  && param.getRepositoryValue() != null
                  && param.getRepositoryValue().equals("ENCODING")) { // $NON-NLS-1$
                setToCustom = true;
              }
              String tempValue = null;
              IElementParameter iElementParameter = null;
              Map<String, IElementParameter> childParameters = param.getChildParameters();
              if (childParameters != null) {
                iElementParameter = childParameters.get(EParameterName.ENCODING_TYPE.getName());
                if (iElementParameter != null) {
                  tempValue = (String) iElementParameter.getValue();
                }
              }
              if (tempValue != null && !tempValue.equals(EmfComponent.ENCODING_TYPE_CUSTOM)) {
                tempValue = tempValue.replaceAll("'", ""); // $NON-NLS-1$ //$NON-NLS-2$
                tempValue = tempValue.replaceAll("\"", ""); // $NON-NLS-1$ //$NON-NLS-2$
                tempValue = TalendTextUtils.addQuotes(tempValue);
                if (!tempValue.equals(value)) {
                  setToCustom = true;
                }
              }

              if (iElementParameter != null && setToCustom) {
                iElementParameter.setValue(EmfComponent.ENCODING_TYPE_CUSTOM);
              }
              elemParam.setPropertyValue(pTypeName, value);
              // end of fix for bug 2193
            } else if (!param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) {
              if (param.getRepositoryValue() != null
                  && !param.getFieldType().equals(EParameterFieldType.PROPERTY_TYPE)) {
                if (repositoryParam != null
                    && EmfComponent.REPOSITORY.equals(repositoryParam.getValue())) {
                  param.setRepositoryValueUsed(true);
                } else {
                  param.setRepositoryValueUsed(false);
                }
              }
              elemParam.setPropertyValue(pTypeName, value);
            }
          } else if (UpdateTheJobsActionsOnTable.isClear
              && "CLEAR_TABLE".equals(pTypeName) // $NON-NLS-1$
              && "true".equals(pType.getValue()) // $NON-NLS-1$
              && "NONE"
                  .equals(
                      elemParam
                          .getElementParameter(Process.TABLE_ACTION)
                          .getValue())) { //$NON-NLS-1$
            elemParam.setPropertyValue(Process.TABLE_ACTION, "CLEAR"); // $NON-NLS-1$
            UpdateTheJobsActionsOnTable.isClear = false;
          }
        }
      }
    }

    // update combo list for dbversion
    if (statsDBType != null && statsDBVersion != null) {
      JobSettingVersionUtil.setDbVersion(
          statsDBVersion,
          String.valueOf(statsDBType.getValue()),
          String.valueOf(statsDBVersion.getValue()));
    }
    if (implicitDBType != null && implicitDBVersion != null) {
      JobSettingVersionUtil.setDbVersion(
          implicitDBVersion,
          String.valueOf(implicitDBType.getValue()),
          String.valueOf(implicitDBVersion.getValue()));
    }
  }
コード例 #7
0
  @Override
  public void execute() {
    if (result == null) {
      return;
    }
    Object job = result.getJob();
    if (job == null) {
      return;
    }
    if (job instanceof IProcess2) {
      Process process = (Process) job;

      EComponentCategory category = null;
      IUpdateItemType updateType = result.getUpdateType();
      if (updateType instanceof EUpdateItemType) {
        switch ((EUpdateItemType) updateType) {
          case JOB_PROPERTY_EXTRA:
            category = EComponentCategory.EXTRA;
            break;
          case JOB_PROPERTY_STATS_LOGS:
            category = EComponentCategory.STATSANDLOGS;
            break;
          case JOB_PROPERTY_HEADERFOOTER:
            category = EComponentCategory.HEADERFOOTER;
            break;
          case JOB_PROPERTY_MAPREDUCE:
            category = EComponentCategory.MAPREDUCE_JOB_CONFIG_FOR_HADOOP;
            break;
          default:
        }
        if (category == EComponentCategory.HEADERFOOTER) {
          if (result.getResultType() == EUpdateResult.UPDATE) {

            if (result.isChecked()) {
              for (IElementParameter param : process.getElementParameters()) {
                if (param.getCategory() == EComponentCategory.HEADERFOOTER) {
                  IElementParameter headerIDParameter =
                      process.getElementParameter(EParameterName.HEADERFOOTER_HEADERID.getName());
                  if (headerIDParameter != null) {
                    IRepositoryViewObject lastVersion =
                        UpdateRepositoryUtils.getRepositoryObjectById(
                            (String) headerIDParameter.getValue());
                    HeaderFooterConnection repositoryConnection = null;
                    if (lastVersion != null) {
                      final Item item = lastVersion.getProperty().getItem();
                      if (item != null && item instanceof ConnectionItem) {
                        repositoryConnection =
                            (HeaderFooterConnection)
                                ((HeaderFooterConnectionItem) item).getConnection();
                        if (repositoryConnection != null) {
                          Boolean isHeader = repositoryConnection.isIsHeader();
                          String libraries = repositoryConnection.getLibraries();
                          String mainCode = repositoryConnection.getMainCode();
                          String imports = repositoryConnection.getImports();
                          process
                              .getElementParameter(EParameterName.HEADER_ENABLED.getName())
                              .setValue(isHeader);
                          process
                              .getElementParameter(EParameterName.HEADER_LIBRARY.getName())
                              .setValue(libraries);
                          process
                              .getElementParameter(EParameterName.HEADER_CODE.getName())
                              .setValue(mainCode);
                          process
                              .getElementParameter(EParameterName.HEADER_IMPORT.getName())
                              .setValue(imports);
                        }
                      }
                    }
                  }

                  IElementParameter footerIDParameter =
                      process.getElementParameter(EParameterName.HEADERFOOTER_FOOTERID.getName());
                  if (footerIDParameter != null) {
                    IRepositoryViewObject lastVersion =
                        UpdateRepositoryUtils.getRepositoryObjectById(
                            (String) footerIDParameter.getValue());
                    HeaderFooterConnection repositoryConnection = null;
                    if (lastVersion != null) {
                      final Item item = lastVersion.getProperty().getItem();
                      if (item != null && item instanceof ConnectionItem) {
                        repositoryConnection =
                            (HeaderFooterConnection)
                                ((HeaderFooterConnectionItem) item).getConnection();
                        if (repositoryConnection != null) {
                          Boolean isHeader = repositoryConnection.isIsHeader();
                          String libraries = repositoryConnection.getLibraries();
                          String mainCode = repositoryConnection.getMainCode();
                          String imports = repositoryConnection.getImports();
                          process
                              .getElementParameter(EParameterName.FOOTER_ENABLED.getName())
                              .setValue(!isHeader);
                          process
                              .getElementParameter(EParameterName.FOOTER_LIBRARY.getName())
                              .setValue(libraries);
                          process
                              .getElementParameter(EParameterName.FOOTER_CODE.getName())
                              .setValue(mainCode);
                          process
                              .getElementParameter(EParameterName.FOOTER_IMPORT.getName())
                              .setValue(imports);
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        } else if (category != null) {
          boolean repository = false;

          if (result.getResultType() == EUpdateResult.UPDATE) {
            // upgrade from repository
            if (result.isChecked()) {
              IElementParameter property =
                  process.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE, category);
              if (property != null) {
                Map<String, IElementParameter> childParameters = property.getChildParameters();
                if (childParameters != null) {
                  IElementParameter elementParameter =
                      childParameters.get(EParameterName.PROPERTY_TYPE.getName());
                  // is repository
                  if (elementParameter != null
                      && EmfComponent.REPOSITORY.equals(elementParameter.getValue())) {
                    for (IElementParameter param : process.getElementParameters()) {
                      if (param.getCategory() != category) {
                        continue;
                      }
                      String repositoryValue = param.getRepositoryValue();
                      if (param.isShow(process.getElementParameters())
                          && (repositoryValue != null)
                          && (!param.getName().equals(EParameterName.PROPERTY_TYPE.getName()))) {
                        Object objectValue =
                            RepositoryToComponentProperty.getValue(
                                (org.talend.core.model.metadata.builder.connection.Connection)
                                    result.getParameter(),
                                repositoryValue,
                                null);
                        if (objectValue != null) {
                          if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST)
                              && repositoryValue.equals(UpdatesConstants.TYPE)) {
                            boolean found = false;
                            String[] items = param.getListRepositoryItems();
                            for (int i = 0; (i < items.length) && (!found); i++) {
                              if (objectValue.equals(items[i])) {
                                found = true;
                                process.setPropertyValue(
                                    param.getName(), param.getListItemsValue()[i]);
                              }
                            }
                          } else if (EParameterName.HADOOP_ADVANCED_PROPERTIES
                              .getName()
                              .equals(param.getName())) {
                            List<Map> list = (ArrayList) param.getValue();
                            for (Map map : list) {
                              if (map.get("BUILDIN") != null && map.get("BUILDIN").equals("TRUE")) {
                                if (objectValue instanceof List) {
                                  ((List) objectValue).add(map);
                                }
                              }
                            }
                            process.setPropertyValue(param.getName(), objectValue);

                          } else {
                            process.setPropertyValue(param.getName(), objectValue);
                          }
                          param.setRepositoryValueUsed(true);
                          param.setReadOnly(true);
                          repository = true;
                        }
                      }
                    }
                  }
                }
              }
            }
          }
          if (!repository) {
            IElementParameter property =
                process.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE, category);
            if (property != null) {
              Map<String, IElementParameter> childParameters = property.getChildParameters();
              if (childParameters != null) {
                IElementParameter elementParameter =
                    childParameters.get(EParameterName.PROPERTY_TYPE.getName());
                elementParameter.setValue(EmfComponent.BUILTIN);
              }
            }

            // built-in
            IElementParameter dbTypeParam = null;
            IElementParameter impliciteDbType = null;
            for (IElementParameter param : process.getElementParameters()) {
              if (param.getCategory() != category) {
                continue;
              }
              String repositoryValue = param.getRepositoryValue();
              if (param.isShow(process.getElementParameters()) && (repositoryValue != null)) {
                // for mysql db verion
                if (EParameterName.DB_TYPE.getName().equals(param.getName())
                    && "TYPE".equals(repositoryValue)) {
                  dbTypeParam = param;
                }
                if ("DB_TYPE_IMPLICIT_CONTEXT".equals(param.getName())
                    && "TYPE".equals(repositoryValue)) {
                  impliciteDbType = param;
                }
                if (EParameterName.DB_VERSION.getName().equals(repositoryValue)
                    && dbTypeParam != null
                    && dbTypeParam.getValue() != null) {
                  final int indexOfItem =
                      dbTypeParam.getIndexOfItemFromList(dbTypeParam.getValue().toString());
                  String dbType = dbTypeParam.getListItemsDisplayCodeName()[indexOfItem];
                  setDBVersionForMysql(param, dbType);
                } else if (EParameterName.DB_VERSION.getName().equals(repositoryValue)
                    && impliciteDbType != null
                    && impliciteDbType.getValue() != null) {
                  final int indexOfItem =
                      impliciteDbType.getIndexOfItemFromList(impliciteDbType.getValue().toString());
                  String dbType = impliciteDbType.getListItemsDisplayCodeName()[indexOfItem];
                  setDBVersionForMysql(param, dbType);
                }
                param.setRepositoryValueUsed(false);
                param.setReadOnly(false);
              }
            }
          }
        }
      } // else { // for extension
    }
  }
コード例 #8
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
   */
  @Override
  public Control createControl(
      final Composite subComposite,
      final IElementParameter param,
      final int numInRow,
      final int nbInRow,
      final int top,
      final Control lastControl) {
    this.curParameter = param;
    FormData data;
    Button btnEdit = getWidgetFactory().createButton(subComposite, "", SWT.PUSH); // $NON-NLS-1$

    btnEdit.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));

    data = new FormData();
    data.left = new FormAttachment(0, 120);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    btnEdit.setLayoutData(data);
    btnEdit.setData(NAME, ICON_SELECTION);
    btnEdit.setData(PARAMETER_NAME, param.getName());
    btnEdit.setEnabled(!param.isReadOnly());
    btnEdit.addSelectionListener(listenerSelection);

    DecoratedField dField =
        new DecoratedField(
            subComposite,
            SWT.NONE,
            new IControlCreator() {

              @Override
              public Control createControl(Composite parent, int style) {

                return new Label(parent, style);
              }
            });
    // revert btn
    Button btnRevert =
        getWidgetFactory()
            .createButton(
                subComposite,
                Messages.getString("IconSelectionController.Revert"),
                SWT.PUSH); //$NON-NLS-1$

    data = new FormData();
    data.left = new FormAttachment(btnEdit, 5);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    btnRevert.setLayoutData(data);
    btnRevert.setData(NAME, ICON_REVERT);
    btnRevert.setData(PARAMETER_NAME, param.getName());
    btnRevert.setEnabled(!param.isReadOnly());
    btnRevert.addSelectionListener(listenerSelection);

    if (param.isRequired()) {
      FieldDecoration decoration =
          FieldDecorationRegistry.getDefault()
              .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
      dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    if (param.isRepositoryValueUsed()) {
      FieldDecoration decoration =
          FieldDecorationRegistry.getDefault()
              .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
      decoration.setDescription(
          Messages.getString("FileController.decoration.description")); // $NON-NLS-1$
      dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }

    Control cLayout = dField.getLayoutControl();
    filePathText = (Label) dField.getControl();
    String file = (String) elem.getPropertyValue(PARAMETER_NAME);
    if (file != null) {
      // ImageData imageData = new ImageData(file);
      // image = new Image(composite.getShell().getDisplay(), imageData);
      // filePathText.setImage(image);
    }

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName(), 0);
    data = new FormData();
    if (lastControl != null) {
      data.left = new FormAttachment(lastControl, 0);
    } else {
      data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
      labelLabel.setAlignment(SWT.RIGHT);
    }

    // **************************
    data = new FormData();
    int currentLabelWidth = 50;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();

    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
      currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
      if (lastControl != null) {
        data.left = new FormAttachment(lastControl, currentLabelWidth);
      } else {
        data.left = new FormAttachment(0, currentLabelWidth);
      }
    } else {
      data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.top = new FormAttachment(btnEdit, 0, SWT.CENTER);
    data.height = 34;
    data.width = 30;
    cLayout.setLayoutData(data);

    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return btnEdit;
  }
コード例 #9
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
   */
  @Override
  public Control createControl(
      final Composite subComposite,
      final IElementParameter param,
      final int numInRow,
      final int nbInRow,
      final int top,
      final Control lastControl) {
    this.curParameter = param;
    this.paramFieldType = param.getFieldType();
    int nbLines = param.getNbLines();

    DecoratedField dField =
        new DecoratedField(
            subComposite,
            SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP,
            new SelectAllTextControlCreator());
    if (param.isRequired()) {
      FieldDecoration decoration =
          FieldDecorationRegistry.getDefault()
              .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
      dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    Control cLayout = dField.getLayoutControl();
    Text text = (Text) dField.getControl();

    editionControlHelper.register(param.getName(), text);

    FormData d = (FormData) text.getLayoutData();
    if (getAdditionalHeightSize() != 0) {
      nbLines += this.getAdditionalHeightSize() / text.getLineHeight();
    }
    d.height = text.getLineHeight() * nbLines;
    FormData data;
    text.getParent().setSize(subComposite.getSize().x, text.getLineHeight() * nbLines);
    cLayout.setBackground(subComposite.getBackground());
    // for bug 7580
    if (!(text instanceof Text)) {
      text.setEnabled(!param.isReadOnly());
    } else {
      text.setEditable(!param.isReadOnly());
    }
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
    FontData fontData = new FontData(fontType);
    Font font = new Font(null, fontData);
    addResourceDisposeListener(text, font);
    text.setFont(font);
    if (elem instanceof Node) {
      text.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    addDragAndDropTarget(text);

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    data = new FormData();
    if (lastControl != null) {
      data.left = new FormAttachment(lastControl, 0);
    } else {
      data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
      labelLabel.setAlignment(SWT.RIGHT);
    }
    // *********************
    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();

    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
      currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
      if (lastControl != null) {
        data.left = new FormAttachment(lastControl, currentLabelWidth);
      } else {
        data.left = new FormAttachment(0, currentLabelWidth);
      }

    } else {
      data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    // **********************
    hashCurControls.put(param.getName(), text);

    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);

    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return null;
  }
コード例 #10
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
   */
  @Override
  public Control createControl(
      final Composite subComposite,
      final IElementParameter param,
      final int numInRow,
      final int nbInRow,
      final int top,
      final Control lastControl) {
    if (param.getDisplayName().startsWith("!!")) { // $NON-NLS-1$
      if (param.getFieldType() == EParameterFieldType.MODULE_LIST) {
        param.setDisplayName(EParameterName.MODULE_LIST.getDisplayName());
      }
    }

    DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, cbCtrl);
    if (param.isRequired()) {
      FieldDecoration decoration =
          FieldDecorationRegistry.getDefault()
              .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
      dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }

    Control cLayout = dField.getLayoutControl();
    CCombo combo = (CCombo) dField.getControl();

    combo.setEditable(false);
    cLayout.setBackground(subComposite.getBackground());
    combo.setEnabled(!param.isReadOnly());
    combo.addSelectionListener(listenerSelection);
    if (elem instanceof Node) {
      combo.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    FormData data = new FormData();
    if (lastControl != null) {
      data.left = new FormAttachment(lastControl, 0);
    } else {
      data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
      labelLabel.setAlignment(SWT.RIGHT);
    }
    // *********************
    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();

    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
      currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
      if (lastControl != null) {
        data.left = new FormAttachment(lastControl, currentLabelWidth);
      } else {
        data.left = new FormAttachment(0, currentLabelWidth);
      }

    } else {
      data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);

    Button btnEdit = getWidgetFactory().createButton(subComposite, "", SWT.PUSH); // $NON-NLS-1$
    btnEdit.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));

    data = new FormData();
    data.left = new FormAttachment(cLayout, 0, SWT.RIGHT);
    data.right =
        new FormAttachment(
            cLayout, ITabbedPropertyConstants.HSPACE + STANDARD_BUTTON_WIDTH, SWT.RIGHT);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    btnEdit.setLayoutData(data);
    btnEdit.setData(NAME, MODULE);
    btnEdit.setData(PARAMETER_NAME, param.getName());
    btnEdit.setEnabled(!param.isReadOnly());
    btnEdit.addSelectionListener(listenerSelection);

    // **********************
    hashCurControls.put(param.getName(), combo);
    hashCurControls.put(param.getName() + BUTTON_EDIT, btnEdit);
    updateData();
    // this.dynamicTabbedPropertySection.updateColumnList(null);

    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return cLayout;
  }