@@ -0,0 +1,2594 @@
+/*%0A * JaamSim Discrete Event Simulation%0A * Copyright (C) 2018 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.ui;%0A%0Aimport java.awt.BorderLayout;%0Aimport java.awt.Component;%0Aimport java.awt.Dimension;%0Aimport java.awt.event.ActionListener;%0A%0Aimport javax.swing.ImageIcon;%0Aimport javax.swing.JButton;%0Aimport javax.swing.JPanel;%0Aimport javax.swing.JTable;%0Aimport javax.swing.JTextField;%0A%0Aimport com.jaamsim.input.Input;%0A%0Apublic abstract class ChooserEditor extends CellEditor%0Aimplements ActionListener %7B%0A%0A%09private final JPanel jPanel;%0A%09private final JTextField text;%0A%09private final JButton button;%0A%0A%09public ChooserEditor(JTable table, boolean showButton) %7B%0A%09%09super(table);%0A%0A%09%09// Table cell%0A%09%09jPanel = new JPanel(new BorderLayout());%0A%09%09int height = table.getRowHeight();%0A%09%09int width = table.getColumnModel().getColumn(EditBox.VALUE_COLUMN).getWidth() -%0A%09%09%09%09table.getColumnModel().getColumnMargin();%0A%09%09jPanel.setPreferredSize(new Dimension(width, height));%0A%0A%09%09// Editable text%0A%09%09text = new JTextField();%0A%09%09jPanel.add(text, BorderLayout.WEST);%0A%0A%09%09// Dropdown button%0A%09%09int buttonWidth = 0;%0A%09%09if (showButton) %7B%0A%09%09%09button = new JButton(new ImageIcon(%0A%09%09%09%09%09GUIFrame.class.getResource(%22/resources/images/dropdown.png%22)));%0A%09%09%09button.addActionListener(this);%0A%09%09%09button.setActionCommand(%22button%22);%0A%09%09%09buttonWidth = height;%0A%09%09%09button.setPreferredSize(new Dimension(buttonWidth, height));%0A%09%09%09jPanel.add(button, BorderLayout.EAST);%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09button = null;%0A%09%09%7D%0A%0A%09%09text.setPreferredSize(new Dimension(width - buttonWidth, height));%0A%09%7D%0A%0A%09public void setValue(String str) %7B%0A%09%09text.setText(str);%0A%09%7D%0A%0A%09@Override%0A%09public String getValue() %7B%0A%09%09return text.getText();%0A%09%7D%0A%0A%09@Override%0A%09public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) %7B%0A%0A%09%09setTableInfo(table, row, column);%0A%0A%09%09// set the value%0A%09%09input = (Input%3C?%3E)value;%0A%09%09String val = input.getValueString();%0A%09%09if (canRetry() && retryString != null) %7B%0A%09%09%09val = retryString;%0A%09%09%09retryString = null;%0A%09%09%7D%0A%09%09text.setText(val);%0A%0A%09%09return jPanel;%0A%09%7D%0A%0A%7D%0A

add ChooserEditor to provide common functionality for EditBox editors