public void changeConnectionType() { XulListitem selectedItem = (XulListitem) connectionType.getSelectedItem(); String selectedValue = selectedItem.getLabel(); if (selectedValue.equals("Oracle")) { try { XulDomContainer container = this.xulDomContainer.loadFragment("org/pentaho/ui/xul/samples/datasource_oracle.xul"); XulGroupbox newBox = (XulGroupbox) container.getDocumentRoot().getRootElement(); XulGroupbox oldBox = (XulGroupbox) document.getElementById("database-options-box"); document.getElementById("button-box").replaceChild(oldBox, newBox); } catch (Exception e) { System.out.println("XulException loading fragment: " + e.getMessage()); e.printStackTrace(System.out); } } // hostName.setValue( String.format("%s host name", selectedValue) ); // databaseName.setValue( String.format("%s database name", selectedValue) ); // portNumber.setValue( String.format("%s port number", selectedValue) ); // username.setValue( String.format("%s username", selectedValue) ); // password.setValue( String.format("%s password", selectedValue) ); // }
@Test public void testItemLabel() throws Exception { XulListitem item1 = (XulListitem) doc.getElementById("listItem1"); assertEquals("ODBC", item1.getLabel()); item1.setLabel("foo"); assertEquals("foo", item1.getLabel()); }
@Test public void testGetSelectedItems() throws Exception { list.setSelectedIndex(2); XulListitem item = (XulListitem) doc.getElementById("listItem2"); Object[] selectedItems = list.getSelectedItems(); assertEquals(1, selectedItems.length); assertEquals(selectedItems[0], item.getLabel()); }
@Test public void testGetSelectedValue() throws Exception { list.setSelectedIndex(2); XulListitem item = (XulListitem) doc.getElementById("listItem2"); assertEquals(item.getLabel(), list.getSelectedItem()); }
@Test public void testItemValue() throws Exception { XulListitem item1 = (XulListitem) doc.getElementById("listItem1"); item1.setValue("bar"); assertEquals("bar", item1.getValue()); }