use of org.pentaho.ui.xul.XulDomContainer in project pentaho-kettle by pentaho.
the class DatabaseDialogHarness method showDialog.
private void showDialog() {
XulDomContainer container = null;
try {
DatabaseConnectionDialog dcDialog = new DatabaseConnectionDialog();
container = dcDialog.getSwtInstance(new Shell(SWT.NONE));
if (database != null) {
container.getEventHandler("dataHandler").setData(database);
}
} catch (XulException e) {
e.printStackTrace();
}
XulRoot root = (XulRoot) container.getDocumentRoot().getRootElement();
if (root instanceof XulDialog) {
((XulDialog) root).show();
}
if (root instanceof XulWindow) {
((XulWindow) root).open();
}
try {
database = (DatabaseMeta) container.getEventHandler("dataHandler").getData();
} catch (Exception e) {
e.printStackTrace();
}
String message = DatabaseDialogHarness.setMessage(database);
Shell shell = new Shell(SWT.DIALOG_TRIM);
shell.setLayout(new RowLayout());
Label label = new Label(shell, SWT.NONE);
label.setText(message);
Button button = new Button(shell, SWT.NONE);
button.setText("Edit Database ...");
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
try {
showDialog();
} catch (Exception e) {
e.printStackTrace();
}
}
});
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!shell.getDisplay().readAndDispatch()) {
shell.getDisplay().sleep();
}
}
}
use of org.pentaho.ui.xul.XulDomContainer in project pentaho-kettle by pentaho.
the class SwingTest method showDialog.
private void showDialog(final Document doc) {
XulDomContainer container = null;
try {
container = new SwingXulLoader().loadXul(DatabaseConnectionDialog.DIALOG_DEFINITION_FILE, Messages.getBundle());
if (database != null) {
container.getEventHandler("dataHandler").setData(database);
}
} catch (Exception e) {
e.printStackTrace();
}
XulDialog dialog = (XulDialog) container.getDocumentRoot().getRootElement();
container.initialize();
dialog.show();
try {
@SuppressWarnings("unused") Object data = container.getEventHandler("dataHandler").getData();
} catch (XulException e) {
System.out.println("Error getting data");
}
}
use of org.pentaho.ui.xul.XulDomContainer in project pentaho-kettle by pentaho.
the class DataHandlerTest method setUp.
@Before
public void setUp() throws Exception {
dataHandler = new DataHandler();
xulDomContainer = mock(XulDomContainer.class);
document = mock(Document.class);
XulComponent rootElement = mock(XulComponent.class);
when(document.getRootElement()).thenReturn(rootElement);
// Mock the UI components
accessBox = mock(XulListbox.class);
when(document.getElementById("access-type-list")).thenReturn(accessBox);
connectionBox = mock(XulListbox.class);
when(document.getElementById("connection-type-list")).thenReturn(connectionBox);
connectionNameBox = mock(XulTextbox.class);
when(document.getElementById("connection-name-text")).thenReturn(connectionNameBox);
dialogDeck = mock(XulDeck.class);
when(document.getElementById("dialog-panel-deck")).thenReturn(dialogDeck);
deckOptionsBox = mock(XulListbox.class);
when(document.getElementById("deck-options-list")).thenReturn(deckOptionsBox);
hostNameBox = mock(XulTextbox.class);
when(document.getElementById("server-host-name-text")).thenReturn(hostNameBox);
databaseNameBox = mock(XulTextbox.class);
when(document.getElementById("database-name-text")).thenReturn(databaseNameBox);
portNumberBox = mock(XulTextbox.class);
when(document.getElementById("port-number-text")).thenReturn(portNumberBox);
userNameBox = mock(XulTextbox.class);
when(document.getElementById("username-text")).thenReturn(userNameBox);
passwordBox = mock(XulTextbox.class);
when(document.getElementById("password-text")).thenReturn(passwordBox);
serverInstanceBox = mock(XulTextbox.class);
when(document.getElementById("instance-text")).thenReturn(serverInstanceBox);
when(serverInstanceBox.getValue()).thenReturn("instance");
when(serverInstanceBox.getAttributeValue("shouldDisablePortIfPopulated")).thenReturn("true");
webappName = mock(XulTextbox.class);
when(document.getElementById("web-application-name-text")).thenReturn(webappName);
when(webappName.getValue()).thenReturn("webappName");
messageBox = mock(XulMessageBox.class);
when(document.createElement("messagebox")).thenReturn(messageBox);
when(xulDomContainer.getDocumentRoot()).thenReturn(document);
generalDatasourceWindow = mock(XulRoot.class);
when(generalDatasourceWindow.getRootObject()).thenReturn(mock(XulComponent.class));
when(document.getElementById("general-datasource-window")).thenReturn(generalDatasourceWindow);
dataHandler.setXulDomContainer(xulDomContainer);
}
use of org.pentaho.ui.xul.XulDomContainer in project pentaho-kettle by pentaho.
the class FragmentHandlerTest method testLoadDatabaseOptionsFragment.
@Test
public void testLoadDatabaseOptionsFragment() throws Exception {
XulComponent component = mock(XulComponent.class);
XulComponent parent = mock(XulComponent.class);
when(component.getParent()).thenReturn(parent);
when(document.getElementById("database-options-box")).thenReturn(component);
XulDomContainer fragmentContainer = mock(XulDomContainer.class);
Document mockDoc = mock(Document.class);
XulComponent firstChild = mock(XulComponent.class);
when(mockDoc.getFirstChild()).thenReturn(firstChild);
when(fragmentContainer.getDocumentRoot()).thenReturn(mockDoc);
when(xulDomContainer.loadFragment(anyString(), any(Object.class))).thenReturn(fragmentContainer);
fragmentHandler.loadDatabaseOptionsFragment(null);
}
use of org.pentaho.ui.xul.XulDomContainer in project pentaho-kettle by pentaho.
the class FragmentHandler method loadDatabaseOptionsFragment.
protected void loadDatabaseOptionsFragment(String fragmentUri) throws XulException {
XulComponent groupElement = document.getElementById("database-options-box");
XulComponent parentElement = groupElement.getParent();
XulDomContainer fragmentContainer;
try {
// Get new group box fragment ...
// This will effectively set up the SWT parent child relationship...
fragmentContainer = this.xulDomContainer.loadFragment(fragmentUri, Messages.getBundle());
XulComponent newGroup = fragmentContainer.getDocumentRoot().getFirstChild();
parentElement.replaceChild(groupElement, newGroup);
} catch (XulException e) {
e.printStackTrace();
throw e;
}
}
Aggregations