use of org.pentaho.ui.xul.XulComponent in project pentaho-platform by pentaho.
the class MantleController method refreshPickListMenu.
/**
* Loads an arbitrary <code>FilePickList</code> into a menu
*
* @param pickMenu
* The XulMenuBar to host the menu entries
* @param filePickList
* The files to list in natural order
*/
private void refreshPickListMenu(XulMenubar pickMenu, final AbstractFilePickList<? extends IFilePickItem> filePickList, PickListType type) {
final MenuBar menuBar = (MenuBar) pickMenu.getManagedObject();
menuBar.clearItems();
final String menuClearMessage = Messages.getString(type.getMenuItemKey());
final String clearMessage = Messages.getString(type.getMessageKey());
if (filePickList.size() > 0) {
for (IFilePickItem filePickItem : filePickList.getFilePickList()) {
final String text = filePickItem.getFullPath();
menuBar.addItem(filePickItem.getTitle(), new Command() {
public void execute() {
SolutionBrowserPanel.getInstance().openFile(text, COMMAND.RUN);
}
});
}
menuBar.addSeparator();
menuBar.addItem(menuClearMessage, new Command() {
public void execute() {
// confirm the clear
GwtConfirmBox warning = new GwtConfirmBox();
warning.setHeight(117);
warning.setMessage(clearMessage);
warning.setTitle(menuClearMessage);
warning.setAcceptLabel(Messages.getString("clearRecentAcceptButtonLabel"));
warning.setCancelLabel(Messages.getString("clearRecentCancelButtonLabel"));
warning.addDialogCallback(new XulDialogCallback<String>() {
public void onClose(XulComponent sender, Status returnCode, String retVal) {
if (returnCode == Status.ACCEPT) {
filePickList.clear();
}
}
public void onError(XulComponent sender, Throwable t) {
}
});
warning.show();
}
});
} else {
menuBar.addItem(Messages.getString("empty"), new // $NON-NLS-1$
Command() {
public void execute() {
// Do nothing
}
});
}
}
use of org.pentaho.ui.xul.XulComponent in project data-access by pentaho.
the class MetadataImportDialogController method promptImportMetadata.
/**
* Shows a promt dialog
*
* @param title
* @param message
* @param radioDSWLabel
* @param radioMetaLabel
* @param onResulthandler
*/
private void promptImportMetadata(final String title, final String message, final String radioDSWLabel, final String radioMetaLabel, final AsyncCallback<Boolean> onResulthandler) {
final VerticalPanel panel = new VerticalPanel();
// $NON-NLS-1$
panel.add(new Label(message));
VerticalPanel vp = new VerticalPanel();
HorizontalPanel hp = new HorizontalPanel();
hp.getElement().getStyle().setMarginBottom(10, Style.Unit.PX);
hp.getElement().getStyle().setMarginTop(10, Style.Unit.PX);
final RadioButton dswRadio = new RadioButton("importMetadata");
RadioButton metadataRadio = new RadioButton("importMetadata");
dswRadio.setEnabled(true);
dswRadio.setValue(true);
hp.add(dswRadio);
hp.add(new Label(radioDSWLabel));
vp.add(hp);
HorizontalPanel hp2 = new HorizontalPanel();
hp2.add(metadataRadio);
hp2.add(new Label(radioMetaLabel));
vp.add(hp2);
panel.add(vp);
XulPromptBox promptBox = new GwtPromptBox() {
@Override
public Panel getDialogContents() {
return panel;
}
@Override
public int open() {
super.show();
dswRadio.setFocus(true);
return 0;
}
@Override
public Panel getButtonPanel() {
Panel button = super.getButtonPanel();
return button;
}
};
promptBox.setTitle(title);
promptBox.setAcceptLabel(resBundle.getString("importDialog.DIALOG_OK", "OK"));
promptBox.setCancelLabel(resBundle.getString("importDialog.DIALOG_Cancel", "Cancel"));
promptBox.addDialogCallback(new XulDialogCallback<String>() {
@Override
public void onClose(XulComponent component, Status status, String value) {
if (status == Status.CANCEL) {
onImportCancel();
reShowDialog();
return;
}
if (onResulthandler != null) {
onResulthandler.onSuccess(dswRadio.getValue());
}
}
@Override
public void onError(XulComponent xulComponent, Throwable throwable) {
onResulthandler.onFailure(throwable);
}
});
promptBox.setWidth(460);
promptBox.setHeight(140);
promptBox.open();
}
use of org.pentaho.ui.xul.XulComponent in project pentaho-kettle by pentaho.
the class FragmentHandlerTest method testLoadDatabaseOptionsFragmentWithException.
@Test(expected = XulException.class)
public void testLoadDatabaseOptionsFragmentWithException() 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);
when(xulDomContainer.loadFragment(anyString(), any(Object.class))).thenThrow(new XulException());
fragmentHandler.loadDatabaseOptionsFragment(null);
}
use of org.pentaho.ui.xul.XulComponent in project pentaho-kettle by pentaho.
the class FragmentHandlerTest method testRefreshOptions.
@Test
public void testRefreshOptions() throws Exception {
XulListbox connectionBox = mock(XulListbox.class);
when(document.getElementById("connection-type-list")).thenReturn(connectionBox);
when(connectionBox.getSelectedItem()).thenReturn("myDb");
XulListbox accessBox = mock(XulListbox.class);
when(document.getElementById("access-type-list")).thenReturn(accessBox);
when(accessBox.getSelectedItem()).thenReturn("Native");
DataHandler dataHandler = mock(DataHandler.class);
when(xulDomContainer.getEventHandler("dataHandler")).thenReturn(dataHandler);
DatabaseInterface dbInterface = mock(DatabaseInterface.class);
when(dbInterface.getDefaultDatabasePort()).thenReturn(5309);
DataHandler.connectionMap.put("myDb", dbInterface);
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);
XulTextbox portBox = mock(XulTextbox.class);
when(document.getElementById("port-number-text")).thenReturn(portBox);
fragmentHandler.refreshOptions();
// Iterate through the other database access types
when(accessBox.getSelectedItem()).thenReturn("JNDI");
fragmentHandler.refreshOptions();
when(accessBox.getSelectedItem()).thenReturn("ODBC");
fragmentHandler.refreshOptions();
when(accessBox.getSelectedItem()).thenReturn("OCI");
fragmentHandler.refreshOptions();
when(accessBox.getSelectedItem()).thenReturn("Plugin");
fragmentHandler.refreshOptions();
}
use of org.pentaho.ui.xul.XulComponent in project pentaho-kettle by pentaho.
the class StarModelerPerspective method onFileClose.
public boolean onFileClose() {
int idx = tabbox.getSelectedIndex();
if (idx == -1 || idx >= tabbox.getTabs().getChildNodes().size()) {
return false;
}
try {
if (onTabClose(idx)) {
XulComponent panel = panels.getChildNodes().get(idx);
XulComponent tab = tabs.getChildNodes().get(idx);
panels.removeChild(panel);
tabs.removeChild(tab);
return true;
}
} catch (XulException e) {
e.printStackTrace();
}
return false;
}
Aggregations