@@ -0,0 +1,2483 @@
+/*%0A * JaamSim Discrete Event Simulation%0A * Copyright (C) 2015 Ausenco Engineering Canada Inc.%0A *%0A * This program is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU General Public License as published by%0A * the Free Software Foundation, either version 3 of the License, or%0A * (at your option) any later version.%0A *%0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU General Public License for more details.%0A */%0Apackage com.jaamsim.Graphics;%0A%0Aimport java.util.ArrayList;%0A%0Aimport com.jaamsim.input.Input;%0Aimport com.jaamsim.input.InputAgent;%0Aimport com.jaamsim.input.InputErrorException;%0Aimport com.jaamsim.input.Keyword;%0Aimport com.jaamsim.input.KeywordIndex;%0Aimport com.jaamsim.input.KeywordInput;%0Aimport com.jaamsim.input.Parser;%0Aimport com.jaamsim.ui.GUIFrame;%0A%0Apublic class InputBox extends TextBasics %7B%0A%0A%09@Keyword(description = %22The name of the entity and keyword that will receive the input value.%22,%0A%09         exampleList = %7B%22DisplayEntity1 Size%22%7D)%0A%09protected final KeywordInput target;%0A%0A%09%7B%0A%09%09target = new KeywordInput(%22TargetInput%22, %22Key Inputs%22, null);%0A%09%09target.setRequired(true);%0A%09%09this.addInput(target);%0A%09%7D%0A%0A%09public InputBox() %7B%7D%0A%0A%09@Override%0A%09public void setInputsForDragAndDrop() %7B%0A%09%09super.setInputsForDragAndDrop();%0A%09%09this.setSavedText(this.getName());%0A%09%7D%0A%0A%09@Override%0A%09public void updateForInput(Input%3C?%3E in) %7B%0A%09%09super.updateForInput(in);%0A%0A%09%09if (in == target) %7B%0A%09%09%09cancelEdits();%0A%09%09%09return;%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09public void acceptEdits() %7B%0A%09%09try %7B%0A%09%09%09ArrayList%3CString%3E tokens = new ArrayList%3C%3E();%0A%09%09%09Parser.tokenize(tokens, getEditText(), true);%0A%09%09%09KeywordIndex kw = new KeywordIndex(target.getValue(), tokens, null);%0A%09%09%09InputAgent.apply(target.getTargetEntity(), kw);%0A%09%09%09super.acceptEdits();%0A%09%09%7D%0A%09%09catch (InputErrorException e) %7B%0A%09%09%09GUIFrame.invokeErrorDialog(%22Input Error%22, e.getMessage());%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09public void handleSelectionLost() %7B%0A%09%09super.handleSelectionLost();%0A%0A%09%09// Stop editing, even if the inputs were not accepted successfully%0A%09%09cancelEdits();%0A%09%7D%0A%0A%09@Override%0A%09public String getCachedText() %7B%0A%09%09Input%3C?%3E targetInput = target.getTargetInput();%0A%09%09if (!isEditMode() && targetInput != null) %7B%0A%09%09%09String str = targetInput.getValueString();%0A%09%09%09if (str.isEmpty())%0A%09%09%09%09str = targetInput.getDefaultString();%0A%09%09%09this.setSavedText(str);%0A%09%09%7D%0A%09%09return getEditText();%0A%09%7D%0A%0A%7D%0A

add an object for entering input data to a model