/** * Removes the given operator. Don't call this method directly but call {@link Operator#remove()}. */ protected void removeOperator(Operator operator) { if (!operators.contains(operator)) { throw new NoSuchElementException( "Operator " + operator.getName() + " not contained in " + getName() + "!"); } int oldIndex = operators.indexOf(operator); int oldIndexAmongEnabled = getEnabledOperators().indexOf(operator); operators.remove(operator); unregister(operator); // operator.disconnectPorts(); // transformMDNeighbourhood(); Process process = getEnclosingOperator().getProcess(); if (process != null) { process.fireOperatorRemoved(operator, oldIndex, oldIndexAmongEnabled); } operator.setEnclosingProcess(null); fireUpdate(this); }
/** * Moves an operator to the given index. (If the old index is smaller than the new one, the new * one will automatically be reduced by one.) */ public void moveToIndex(Operator op, int newIndex) { int oldIndex = operators.indexOf(op); Process process = getEnclosingOperator().getProcess(); if (oldIndex != -1) { operators.remove(op); if (process != null) { int oldIndexAmongEnabled = getEnabledOperators().indexOf(op); process.fireOperatorRemoved(op, oldIndex, oldIndexAmongEnabled); } if (oldIndex < newIndex) { newIndex--; } operators.add(newIndex, op); if (process != null) { process.fireOperatorAdded(op); } fireUpdate(); updateExecutionOrder(); } }