/*
   * Validate the input against the underlying type.
   */
  public static String isValueValid(String newValue) {
    IStructuredSelection currentSelection = Selection.getInstance().getStructuredSelection();
    Object context = currentSelection.iterator().next();
    LiteralSymbolicConstant_c v_lsc = (LiteralSymbolicConstant_c) context;

    SymbolicConstant_c v_symConst =
        SymbolicConstant_c.getOneCNST_SYCOnR1502(
            LeafSymbolicConstant_c.getOneCNST_LFSCOnR1503(v_lsc));

    DataType_c v_dt = DataType_c.getOneS_DTOnR1500(v_symConst);

    return InputValueValidator.isValid(v_dt, newValue);
  }
 public void testGlobalMigrationSymbolicConstantDomain() throws Exception {
   Ooaofooa testRoot =
       Ooaofooa.getInstance("/model_upgrade/models/model_upgrade/domain/domain.xtuml");
   SymbolicConstant_c param = SymbolicConstant_c.SymbolicConstantInstance(testRoot);
   assertNotNull("Unable to locate test element", param);
   DataType_c dt = DataType_c.getOneS_DTOnR1500(param);
   assertNotNull("Unable to locate test element", dt);
   GlobalElementInSystem_c gis =
       GlobalElementInSystem_c.getOneG_EISOnR9100(PackageableElement_c.getOnePE_PEOnR8001(dt));
   assertNotNull("SymbolicConstant was not migrated to use globals.", gis);
   assertTrue(
       "Incorrect data type associated with SymbolicConstant after global migration",
       dt.getName().equals("string"));
 }
  private void CNST_CSP_NewConstant(IStructuredSelection selection) {
    // Assign the context selection variables with the action context
    // Assign the context selection variable with the action context
    Object context = selection.iterator().next();
    ConstantSpecification_c v_csp = (ConstantSpecification_c) context;
    PersistableModelComponent.ensureCoreDataTypesAvailable(v_csp.getModelRoot());

    TransactionUtil.TransactionGroup transactionGroup =
        TransactionUtil.startTransactionsOnSelectedModelRoots("New Constant");
    boolean abortTransaction = false;
    try {
      // Ensure that actions take place between Verifier Activity executions
      Ooaofooa.beginSaveOperation();
      if (v_csp != null) {
        v_csp.Newliteralsymbolicconstant();
      } else {
        Throwable t = new Throwable();
        t.fillInStackTrace();
        CorePlugin.logError("Attempted to call an operation on a null instance.", t);
      }

      NonRootModelElement[] children =
          LiteralSymbolicConstant_c.getManyCNST_LSCsOnR1503(
              LeafSymbolicConstant_c.getManyCNST_LFSCsOnR1502(
                  SymbolicConstant_c.getManyCNST_SYCsOnR1504(v_csp)));

      NonRootModelElement newElement = children[children.length - 1];
      IPreferenceStore store = CorePlugin.getDefault().getPreferenceStore();
      boolean option = store.getBoolean(BridgePointPreferencesStore.USE_DEFAULT_NAME_FOR_CREATION);
      if (!option) {
        String oldName = RenameActionUtil.getElementName(newElement);
        boolean performRename =
            UIUtil.inputDialog(
                null,
                "Element Creation",
                "Enter the name:",
                oldName,
                UIUtil.newRenameValidator(newElement));
        if (performRename) {
          String proposedName = UIUtil.inputDialogResult;
          RenameActionUtil.setElementName(newElement, proposedName);
          newElement.setComponent(null);
        } else {
          abortTransaction = true;
        }
      }
      // end critical section
      Ooaofooa.endSaveOperation();
      // catch all exceptions and cancel the transactions
    } catch (Exception e) {
      Ooaofooa.endSaveOperation();
      TransactionUtil.cancelTransactions(transactionGroup, e);
      CorePlugin.logError("Transaction: New Constant failed", e); // $NON-NLS-1$
    }
    if ((!CorePlugin.getDefault()
            .getPreferenceStore()
            .getBoolean(BridgePointPreferencesStore.USE_DEFAULT_NAME_FOR_CREATION))
        && abortTransaction) {
      TransactionUtil.cancelTransactions(transactionGroup);
    } else {
      TransactionUtil.endTransactions(transactionGroup);
    }
  }