@@ -0,0 +1,1725 @@
+/*%0A * JaamSim Discrete Event Simulation%0A * Copyright (C) 2017 JaamSim Software Inc.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.jaamsim.Commands;%0A%0Aimport com.jaamsim.basicsim.Entity;%0Aimport com.jaamsim.basicsim.ErrorException;%0Aimport com.jaamsim.input.InputAgent;%0A%0Apublic class DefineCommand implements Command %7B%0A%0A%09private final Class%3C? extends Entity%3E klass;%0A%09private Entity entity;%0A%09private final String entityName;%0A%0A%09public DefineCommand(Class%3C? extends Entity%3E cls, String name) %7B%0A%09%09klass = cls;%0A%09%09entity = null;%0A%09%09entityName = name;%0A%09%7D%0A%0A%09@Override%0A%09public void execute() %7B%0A%0A%09%09// If the entity has been killed by the undo method, then simply restore it to life%0A%09%09if (entity != null) %7B%0A%09%09%09entity.restore(entityName);%0A%09%09%09return;%0A%09%09%7D%0A%0A%09%09// Create the entity%0A%09%09if (Entity.getNamedEntity(entityName) != null) %7B%0A%09%09%09throw new ErrorException(%22Name is already in use. Should never happen.%22);%0A%09%09%7D%0A%09%09entity = InputAgent.defineEntityWithUniqueName(klass, entityName, %22%22, true);%0A%09%7D%0A%0A%09@Override%0A%09public void undo() %7B%0A%09%09entity.kill();%0A%09%7D%0A%0A%09@Override%0A%09public Command tryMerge(Command cmd) %7B%0A%09%09return null;%0A%09%7D%0A%0A%09@Override%0A%09public String toString() %7B%0A%09%09return String.format(%22Create: '%25s'%22, entityName);%0A%09%7D%0A%0A%7D%0A

add DefineCommand