/** Load the gui values from the data object attributes. */ public void loadFromObject() { InterfaceRegistry registry = (InterfaceRegistry) iobject; int row = 0; for (Iterator i = registry.getGagingSystemIterator(); i.hasNext(); ) { gagingSystemTableModel.setValueAt(i.next(), row++, 0); } gagingSystemTable.revalidate(); }
/** Initialize the gui. Subclasses should override this method to create a custom gui. */ public void initGUI() { try { SwingEngine swingEngine = new SwingEngine(this); swingEngine.setClassLoader(AppPlugin.class.getClassLoader()); JPanel panel = (JPanel) swingEngine.render(getClass().getResource("/swixml/GagingSystemListEditor.xml")); content.add(panel, createConstraints(0, 0, 1, 1, GridBagConstraints.BOTH, 100, 100, null)); gagingSystemTableModel = new IObjectTableModel() { private String[] columnNames = new String[] { Engine.instance().getResourceService().getStringWithoutException("metix.name"), Engine.instance().getResourceService().getStringWithoutException("metix.active") }; private Class[] columnClasses = new Class[] {String.class, Boolean.class}; public int getColumnCount() { return columnNames.length; } public String getColumnName(int col) { return columnNames[col]; } public Class getColumnClass(int col) { return columnClasses[col]; } public int getRowCount() { InterfaceRegistry registry = (InterfaceRegistry) iobject; if (registry == null) { return 0; } return registry.getGagingSystemCount(); } public Object getValueAt(int row, int col) { InterfaceRegistry registry = (InterfaceRegistry) iobject; GagingSystem station = (GagingSystem) registry.getGagingSystem(row); switch (col) { case 0: return station.getName(); case 1: return new Boolean(station.getActive()); default: return null; } } }; gagingSystemTableModel.addTableModelListener(this); gagingSystemTable.setModel(gagingSystemTableModel); gagingSystemTable.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { editGagingStationAction.actionPerformed(null); } } }); } catch (Exception x) { Log.logError("client", "GagingSystemListEditor.initGUI", x.toString()); } }