/** * The controller was updated in the table, so we should update the uC * * @param item The item that was updated * @param col The column that was updated * @param text The new text */ public void updateItemWithText(TableItem item, int col, String text) { switch (col) { case 0: // type break; // shouldn't be editable case 1: // name Microcontroller controller = (Microcontroller) item.getData(); item.setText(col, text); controller.setName(text); System.out.println(controller); break; case 2: // port controller = (Microcontroller) item.getData(); item.setText(col, text); controller.establishNewConnectionToPort(text); System.out.println(controller); break; } }
/** Adds an element to the table */ public void addControllerAsRow(Microcontroller controller) { TableItem item = new TableItem(table, SWT.NONE); item.setText( new String[] {controller.getType().getName(), controller.getName(), controller.getPort()}); item.setData(controller); }