public void preWindowOpen() {
    final IWorkbenchWindowConfigurer configurer = getWindowConfigurer();

    configurer.setInitialSize(
        new Point(UnwGUIConstants.MAIN_WINDOW_WIDTH, UnwGUIConstants.MAIN_WINDOW_HEIGHT));

    configurer.setShowCoolBar(true);

    configurer.setShowMenuBar(true);
    configurer.setShowProgressIndicator(true);
    title = UnwGUIConstants.APP_NAME;
    String uid = System.getProperty("user.name").toUpperCase();

    if (!uid.matches("^[AX]\\d+$")) title += "- under NDA or DMA ? No distribution";

    configurer.setTitle(title);

    configurer.setShowProgressIndicator(true);

    UnwInfrastructure.preWindowOpen();

    UnwCore.getDBProject()
        .addProjectChangeListener(
            new DBProjectChangeListener() {
              @Override
              public void projectOpened() {
                configurer.setTitle(title + "- project : " + UnwCore.project.getProjectName());
              }

              @Override
              public void projectClosed() {
                configurer.setTitle(title);
              }
            });
  }
Пример #2
0
  /**
   * @param parentShell
   * @param db : library where the new model is located
   * @param familyName : family of the new model (can be null)
   * @param parentModel : where to add the new instance
   */
  public AddModuleDialog(
      Shell parentShell,
      DB db,
      String familyName,
      WIZARD_TYPE pageType,
      ModelDB parentModel,
      String modelName,
      DesignCreatorDataModel dataModel) {

    super(
        parentShell,
        new AddModuleDialogWizard(
            UnwCore.getDBProject().db(), pageType, parentModel, modelName, dataModel));

    this.db = db;
    currentPage = null;

    wizard = (AddModuleDialogWizard) getWizard();
  }
  public Object execute(List<String> argList) throws TclShellException {
    JSAPResult argv = parse(argList);
    if (argv == null) {
      return false;
    }

    if (argv.getBoolean(SmOptionPM.LIST_ATTR_OPTION)) {
      for (PWR_SRC_ATTR e : PWR_SRC_ATTR.values())
        System.out.println(
            " =>  "
                + e.arg
                + " :\n         "
                + e.help
                + (e.allowed == null ? "" : " = " + StringUtilities.join(", ", e.allowed) + ")"));

      return true;
    }

    String modelID = argv.getString(SmOption.MODEL_OPTION);
    ModelDB model =
        (modelID != null) ? ToolsDesign.getModel(modelID) : UnwCore.getDBProject().model();

    if (model == null) {
      Logger.error(ErrorList.DB3.errorName(), ErrorList.DB3.getMessage(modelID));
      throw new TclShellException("");
    }

    PMConfig cfg = PMResourceManager.instance.getPmconfig(model, null);

    String pwrsrcName = argv.getString(SmOptionPM.PWRSRC_OPTION);

    PowerSourceInstance powerSource = PMFindVDomainTools.findPowerSource(cfg, pwrsrcName);

    if (powerSource == null) {
      Logger.error(
          ErrorListPM.PM22.errorName(),
          ErrorListPM.PM22.getMessage(pwrsrcName + "in model " + model.getModelName()));
      throw new TclShellException("");
    }

    if (!argv.contains(SmOption.NAME_VALUE_OPTION)) {
      Logger.error("TCL", "no attribute specified");
      throw new TclShellException("");
    }

    String[] tokens = argv.getStringArray(SmOption.NAME_VALUE_OPTION);
    if (tokens.length % 2 != 0) {
      Logger.error(ErrorListPM.PM_TCL1.errorName(), ErrorListPM.PM_TCL1.getMessage());
      throw new TclShellException("");
    }

    String attrName;
    String attrValue;
    boolean error = false;

    for (int i = 0; i < tokens.length; i += 2) {
      attrName = tokens[i];
      attrValue = tokens[i + 1];

      PWR_SRC_ATTR id = PWR_SRC_ATTR.findAttr(attrName);

      if (id == null) {
        Logger.error(ErrorListPM.PM_TCL3.errorName(), ErrorListPM.PM_TCL3.getMessage(attrName));
        throw new TclShellException("");

      } else {

        CONNECT_DIRECTIVE direct = null;

        switch (id) {
          case CONNECT_IVOLT:
            try {
              direct = CONNECT_DIRECTIVE.valueOf(attrValue);
              powerSource.setConnectInputVoltage(direct);
            } catch (Exception e) {
              error = true;
            }
            break;

          case CONNECT_CTRL:
            try {
              direct = CONNECT_DIRECTIVE.valueOf(attrValue);
              powerSource.setConnectControl(direct);
            } catch (Exception e) {
              error = true;
            }
            break;

          case NAME:
            if (FormatValidation.isAlphaNumeric(attrValue, false)) {
              powerSource.setName(attrValue);
            } else error = true;

          default:
            break;
        }

        if (error) {
          Logger.error(
              ErrorListPM.PM_TCL2.errorName(),
              ErrorListPM.PM_TCL2.getMessage(attrValue + " for attribute " + attrName));
          throw new TclShellException("");
        }
      }
    }

    return true;
  }