Search in sources :

Example 16 with XulComponent

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
            }
        });
    }
}
Also used : IFilePickItem(org.pentaho.mantle.client.solutionbrowser.filepicklist.IFilePickItem) SwitchThemeCommand(org.pentaho.mantle.client.commands.SwitchThemeCommand) Command(com.google.gwt.user.client.Command) SwitchLocaleCommand(org.pentaho.mantle.client.commands.SwitchLocaleCommand) ShowBrowserCommand(org.pentaho.mantle.client.commands.ShowBrowserCommand) XulDialogCallback(org.pentaho.ui.xul.util.XulDialogCallback) MenuBar(com.google.gwt.user.client.ui.MenuBar) GwtConfirmBox(org.pentaho.ui.xul.gwt.tags.GwtConfirmBox) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 17 with XulComponent

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();
}
Also used : HttpStatus(org.apache.http.HttpStatus) Label(com.google.gwt.user.client.ui.Label) XulLabel(org.pentaho.ui.xul.components.XulLabel) RadioButton(com.google.gwt.user.client.ui.RadioButton) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) RootPanel(com.google.gwt.user.client.ui.RootPanel) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) FormPanel(com.google.gwt.user.client.ui.FormPanel) Panel(com.google.gwt.user.client.ui.Panel) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) GwtPromptBox(org.pentaho.ui.xul.gwt.tags.GwtPromptBox) XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 18 with XulComponent

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);
}
Also used : XulException(org.pentaho.ui.xul.XulException) XulComponent(org.pentaho.ui.xul.XulComponent) Test(org.junit.Test)

Example 19 with XulComponent

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();
}
Also used : DatabaseInterface(org.pentaho.di.core.database.DatabaseInterface) XulTextbox(org.pentaho.ui.xul.components.XulTextbox) XulListbox(org.pentaho.ui.xul.containers.XulListbox) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) Document(org.pentaho.ui.xul.dom.Document) XulComponent(org.pentaho.ui.xul.XulComponent) Test(org.junit.Test)

Example 20 with XulComponent

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;
}
Also used : XulException(org.pentaho.ui.xul.XulException) XulComponent(org.pentaho.ui.xul.XulComponent)

Aggregations

XulComponent (org.pentaho.ui.xul.XulComponent)33 XulException (org.pentaho.ui.xul.XulException)13 KettleException (org.pentaho.di.core.exception.KettleException)8 XulConfirmBox (org.pentaho.ui.xul.components.XulConfirmBox)8 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)7 XulDomContainer (org.pentaho.ui.xul.XulDomContainer)6 XulPromptBox (org.pentaho.ui.xul.components.XulPromptBox)6 XulMenuitem (org.pentaho.ui.xul.components.XulMenuitem)4 Document (org.pentaho.ui.xul.dom.Document)4 Test (org.junit.Test)3 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)3 UIRepositoryObject (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject)3 Bindable (org.pentaho.ui.xul.stereotype.Bindable)3 Label (com.google.gwt.user.client.ui.Label)2 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)2 ArrayList (java.util.ArrayList)2 HttpStatus (org.apache.http.HttpStatus)2 IAclObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.IAclObject)2 ILockObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject)2 UIObjectCreationException (org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException)2