Package lupos.gui.operatorgraph.visualeditor.util

Examples of lupos.gui.operatorgraph.visualeditor.util.ModificationException


      if(!newName.equals("")) {
        HashMap<String, Operator> names = (HashMap<String, Operator>) data;
        Operator tmp = names.get(newName);

        if(tmp != null && !tmp.equals(this.operator)) {
          throw new ModificationException("Name already in use!", this.operator);
        }
        else {
          names.put(newName, this.operator);
        }
      }
View Full Code Here


          if(op1name.startsWith(AbstractRuleOperator.internal_name)) {
            continue;
          }

          if(op0name.equals(op1name) && !op0.getClassType().equals(op1.getClassType())) {
            throw new ModificationException("ERROR: Two operators on both sides have the same name but not the same class type!", op1);
          }
          else if(op0name.equals(op1name) && op0.getClassType().equals(op1.getClassType())) {
            equalOps.add(op0name);
          }
        }
      }

      jumpOps_right.removeAll(jumpOps_left);

      if(jumpOps_right.size() > 0) {
        throw new ModificationException("ERROR: It is not allowed to add JumpOverOperators on the right side which are not present on the left side!", null);
      }


      for(final GraphWrapper gw : visualGraph0.getRootList(false)) {
        this.validateCycles((Operator) gw.getElement(), new LinkedHashSet<Operator>(), false);
      }

      for(final GraphWrapper gw : visualGraph1.getRootList(false)) {
        this.validateCycles((Operator) gw.getElement(), new LinkedHashSet<Operator>(), false);
      }


      final AbstractRuleOperator startNode = this.getStartNode();

      if(startNode == null) {
        return new Triple<Boolean, HashMap<String, VariableContainer>, HashMap<String, VariableContainer>>(true, null, null);
      }

      this.analyze_manage_node(variableList_left, startNode, 0, new HashSet<AbstractRuleOperator>(), new HashMap<Operator, HashSet<Operator>>());

      if(variableList_left.get(startNode.getName()).getDimension() > 0) {
        throw new ModificationException("ERROR: The dimension of the start node must be 0!", null);
      }


      boolean changed = true;
      final LinkedList<HashSet<ConnectionContainer>> connections = this.getConnections();
      final HashSet<ConnectionContainer> rightConnections = connections.get(1);

      if(visualGraph1.getRootList(false).size() > 0) {
        this.analyze_manage_node(variableList_right, (AbstractRuleOperator) visualGraph1.getRootList(false).get(0).getElement(), 0, new HashSet<AbstractRuleOperator>(), new HashMap<Operator, HashSet<Operator>>());
      }

      for(final ConnectionContainer conn : rightConnections) {
        final String parentName = this.getJumpOverName(conn.getParent(), false);
        final String childName = this.getJumpOverName(conn.getChild(), true);

        if(variableList_left.containsKey(childName)) {
          if(!variableList_left.containsKey(parentName) && conn.getMode() != ModeEnum.ALL_PRECEDING) {
            variableList_right.get(parentName).setCountProvider(conn.getChild());
          }

          variableList_right.get(childName).setCountProvider(conn.getChild());
        }

        if(variableList_left.containsKey(parentName)) {
          if(!variableList_left.containsKey(childName) && conn.getMode() != ModeEnum.ALL_SUCCEEDING) {
            variableList_right.get(childName).setCountProvider(conn.getParent());
          }

          variableList_right.get(parentName).setCountProvider(conn.getParent());
        }
      }

      while(changed) {
        changed = false;

        for(final ConnectionContainer conn : rightConnections) {
          final String parentName = this.getJumpOverName(conn.getParent(), false);
          final String childName = this.getJumpOverName(conn.getChild(), true);

          if(variableList_right.get(parentName).getCountProvider() == null && variableList_right.get(childName).getCountProvider() != null) {
            variableList_right.get(parentName).setCountProvider(variableList_right.get(childName).getCountProvider());
            changed = true;
          }
          else if(variableList_right.get(childName).getCountProvider() == null && variableList_right.get(parentName).getCountProvider() != null) {
            variableList_right.get(childName).setCountProvider(variableList_right.get(parentName).getCountProvider());
            changed = true;
          }
        }
      }

      for(final VariableContainer vc : variableList_right.values()) {
        if(vc.getCountProvider() == null) {
          if(!variableList_left.containsKey(vc.getOpName())) {
            throw new ModificationException("ERROR: Can't determine dimension size for operator " + vc.getOpName() + "!", null);
          }
        }
      }

View Full Code Here

        if(inLoop) {
          final ModeEnum mode = ((AnnotationPanel) element.getAnnotationLabel(nextElement)).getMode();

          if(mode == ModeEnum.ALL_PRECEDING || mode == ModeEnum.ALL_SUCCEEDING) {
            throw new ModificationException("The mode '" + mode + "' is not allowed in cycles!", element);
          }
        }
      }

      return;
    }

    visitedNodes.add(op);

    for(final OperatorIDTuple<Operator> sucOpIDt : op.getSucceedingOperators()) {
      final AbstractRuleOperator sucOp = (AbstractRuleOperator) sucOpIDt.getOperator();

      final ModeEnum mode = ((AnnotationPanel) ((AbstractRuleOperator) op).getAnnotationLabel(sucOp)).getMode();

      if(mode == ModeEnum.ALL_SUCCEEDING) {
        foundAllSucceeding = true;
      }
      else if(foundAllSucceeding && mode == ModeEnum.ALL_PRECEDING) {
        throw new ModificationException("It is not allowed to have first ALL_SUCCEEDING and then ALL_PRECEDING!", op);
      }

      this.validateCycles(sucOp, (LinkedHashSet<Operator>) visitedNodes.clone(), foundAllSucceeding);
    }
  }
View Full Code Here

  }

  public void applyChange(final String value) throws ModificationException {
    if(!value.equals("")) {
      if(AbstractPrefixOperator.reservedKeyWords.contains(value)) {
        throw new ModificationException("Operator name can not be a java keyword!", this);
      }
      final Pattern p = Pattern.compile("^[a-z]\\w*$", Pattern.CASE_INSENSITIVE);
      if(!p.matcher(value).matches()) {
        throw new ModificationException("Invalid operator name! Operator name must match /^[a-z]\\w*$/", this);
      }
    }
    this.name = value;
  }
View Full Code Here

        }
        catch(NumberFormatException nfe) {
          HashMap<String, Operator> names = (HashMap<String, Operator>) data;

          if(names.containsKey(idText)) {
            throw new ModificationException("Name already in use!", this.operator);
          }
          else {
            names.put(idText, this.operator);
          }
        }
View Full Code Here

  }

  public void applyChange(String value) throws ModificationException {
    if(!value.equals("")) {
      if(AbstractRuleOperator.reservedKeyWords.contains(value)) {
        throw new ModificationException("Operator name can not be a java keyword!", this);
      }

      Pattern p = Pattern.compile("^[a-z]\\w*$", Pattern.CASE_INSENSITIVE);

      if(!p.matcher(value).matches()) {
        throw new ModificationException("Invalid operator name! Operator name must match /^[a-z]\\w*$/", this);
      }
    }

    this.name = value;
  }
View Full Code Here

      }
    }
    catch(NumberFormatException nfe) {
      if(!value.equals("")) {
        if(AbstractRuleOperator.reservedKeyWords.contains(value)) {
          throw new ModificationException("OperatorID label can not be a java keyword!", this);
        }

        Pattern p = Pattern.compile("^[a-z]\\w*$", Pattern.CASE_INSENSITIVE);

        if(!p.matcher(value).matches()) {
          throw new ModificationException("Invalid operatorID label! OperatorID label must match /^[a-z]\\w*$/", this);
        }

        this.opIDLabel = value;
      }
      else {
View Full Code Here

    }
    else {
      t.printStackTrace();
    }

    throw new ModificationException(t.getMessage(), line, column, this);
  }
View Full Code Here

TOP

Related Classes of lupos.gui.operatorgraph.visualeditor.util.ModificationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.