Search in sources :

Example 1 with XulPromptBox

use of org.pentaho.ui.xul.components.XulPromptBox in project pentaho-kettle by pentaho.

the class BrowseControllerTest method shouldNotCreateFolderOnCloseCreationDialog.

/*
   * Test for {@link BrowseController#createFolder()}.
   *
   * Given an opened folder creation dialog with the non-empty folder name field.
   *
   * When this prompt dialog is just simply closed by pressing 'x' button, then folder should not be created.
   */
@Test
public void shouldNotCreateFolderOnCloseCreationDialog() throws Exception {
    XulPromptBox prompt = new XulPromptBoxMock(XulDialogCallback.Status.CANCEL);
    when(document.createElement(PROMPTBOX)).thenReturn(prompt);
    controller.createFolder();
    assertTrue(directoryMap.isEmpty());
    verify(selectedFolder, never()).createFolder(anyString());
    verify(directoryBinding, never()).fireSourceChanged();
    verify(selectedItemsBinding, never()).fireSourceChanged();
}
Also used : XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) Test(org.junit.Test)

Example 2 with XulPromptBox

use of org.pentaho.ui.xul.components.XulPromptBox in project pentaho-kettle by pentaho.

the class XulDatabaseExplorerController method preview.

public void preview(boolean askLimit) {
    if (model.getTable() == null) {
        return;
    }
    try {
        PromptCallback theCallback = new PromptCallback();
        @SuppressWarnings("unused") boolean execute = true;
        int limit = 100;
        if (askLimit) {
            XulPromptBox thePromptBox = (XulPromptBox) this.document.createElement("promptbox");
            thePromptBox.setModalParent(this.dbExplorerDialog.getShell());
            thePromptBox.setTitle("Enter Max Rows");
            thePromptBox.setMessage("Max Rows:");
            thePromptBox.addDialogCallback(theCallback);
            thePromptBox.open();
            execute = theCallback.getLimit() != -1;
            limit = theCallback.getLimit();
        }
        // if (execute) {
        // XulPreviewRowsDialog thePreviewRowsDialog = new XulPreviewRowsDialog(this.shell, SWT.NONE,
        // this.model.getDatabaseMeta(), this.model.getTable(), theCallback.getLimit());
        // thePreviewRowsDialog.open();
        // }
        GetPreviewTableProgressDialog pd = new GetPreviewTableProgressDialog(this.dbExplorerDialog.getShell(), this.model.getDatabaseMeta(), model.getSchema(), model.getTable(), limit);
        List<Object[]> rows = pd.open();
        if (rows != null) {
            if (rows.size() > 0) {
                PreviewRowsDialog prd = new PreviewRowsDialog(this.dbExplorerDialog.getShell(), this.model.getDatabaseMeta(), SWT.None, this.model.getTable(), pd.getRowMeta(), rows);
                prd.open();
            } else {
                MessageBox mb = new MessageBox(this.dbExplorerDialog.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                mb.setMessage(BaseMessages.getString(PKG, "DatabaseExplorerDialog.NoRows.Message"));
                mb.setText(BaseMessages.getString(PKG, "DatabaseExplorerDialog.NoRows.Title"));
                mb.open();
            }
        }
    } catch (Exception e) {
        LogChannel.GENERAL.logError("Error previewing rows", e);
    }
}
Also used : XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) XulException(org.pentaho.ui.xul.XulException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) XulMessageBox(org.pentaho.ui.xul.components.XulMessageBox) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 3 with XulPromptBox

use of org.pentaho.ui.xul.components.XulPromptBox in project pentaho-kettle by pentaho.

the class RepositoryLockController method lockContent.

public void lockContent() throws Exception {
    List<UIRepositoryObject> selectedRepoObjects = browseController.getSelectedFileItems();
    if (selectedRepoObjects.size() > 0 && selectedRepoObjects.get(0) instanceof UIRepositoryContent) {
        final UIRepositoryContent contentToLock = (UIRepositoryContent) selectedRepoObjects.get(0);
        if (((ILockObject) contentToLock).isLocked()) {
            // Unlock the item
            ((ILockObject) contentToLock).unlock();
            browseController.getSelectedItemsBinding().fireSourceChanged();
        } else {
            // Lock the item
            XulPromptBox lockNotePrompt = promptLockMessage(document, messages, null);
            lockNotePrompt.addDialogCallback(new XulDialogCallback<String>() {

                public void onClose(XulComponent component, Status status, String value) {
                    if (!status.equals(Status.CANCEL)) {
                        try {
                            ((ILockObject) contentToLock).lock(value);
                            browseController.getSelectedItemsBinding().fireSourceChanged();
                        } catch (Exception e) {
                            // convert to runtime exception so it bubbles up through the UI
                            throw new RuntimeException(e);
                        }
                    } else {
                        // $NON-NLS-1$
                        XulMenuitem lockMenuItem = (XulMenuitem) document.getElementById("lock-context-lock");
                        lockMenuItem.setSelected(false);
                        // $NON-NLS-1$
                        lockMenuItem = (XulMenuitem) document.getElementById("file-context-lock");
                        lockMenuItem.setSelected(false);
                    }
                }

                public void onError(XulComponent component, Throwable err) {
                    throw new RuntimeException(err);
                }
            });
            lockNotePrompt.open();
        }
    }
}
Also used : UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) ILockObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject) XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 4 with XulPromptBox

use of org.pentaho.ui.xul.components.XulPromptBox in project pentaho-kettle by pentaho.

the class BrowseController method createFolder.

public void createFolder() throws Exception {
    try {
        Collection<UIRepositoryDirectory> directories = folderTree.getSelectedItems();
        if (directories == null || directories.size() == 0) {
            return;
        }
        UIRepositoryDirectory selectedFolder = directories.iterator().next();
        // First, ask for a name for the folder
        XulPromptBox prompt = promptForName(null);
        prompt.addDialogCallback(new XulDialogCallback<String>() {

            public void onClose(XulComponent component, Status status, String value) {
                if (status == Status.ACCEPT) {
                    newName = value;
                } else {
                    newName = null;
                }
            }

            public void onError(XulComponent component, Throwable err) {
                throw new RuntimeException(err);
            }
        });
        prompt.open();
        if (newName != null) {
            if (selectedFolder == null) {
                selectedFolder = repositoryDirectory;
            }
            // Do an explicit check here to see if the folder already exists in the ui
            // This is to prevent a double message being sent in case the folder does
            // not exist in the ui but does exist in the repo (PDI-5202)
            boolean folderExistsInUI = selectedFolder.contains(newName);
            if (folderExistsInUI) {
                throw new Exception(BaseMessages.getString(PKG, "BrowserController.DirAlreadyExistsInUI", newName));
            }
            // PDI-5202
            String newNameInRepo = selectedFolder.checkDirNameExistsInRepo(newName);
            if (newNameInRepo != null) {
                messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Warning"));
                messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
                messageBox.setMessage(BaseMessages.getString(PKG, "BrowserController.DirAlreadyExistsInRepository", newNameInRepo));
                messageBox.open();
                newName = newNameInRepo;
            }
            UIRepositoryDirectory newDir = selectedFolder.createFolder(newName);
            dirMap.put(newDir.getObjectId(), newDir);
            directoryBinding.fireSourceChanged();
            selectedItemsBinding.fireSourceChanged();
            this.folderTree.setSelectedItems(Collections.singletonList(selectedFolder));
        }
        newName = null;
    } catch (Exception e) {
        if (mainController == null || !mainController.handleLostRepository(e)) {
            confirm(BaseMessages.getString(PKG, "Dialog.Error"), e.getLocalizedMessage());
        }
    }
}
Also used : UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) XulComponent(org.pentaho.ui.xul.XulComponent) XulException(org.pentaho.ui.xul.XulException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) UIObjectCreationException(org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException) KettleException(org.pentaho.di.core.exception.KettleException)

Example 5 with XulPromptBox

use of org.pentaho.ui.xul.components.XulPromptBox in project pentaho-kettle by pentaho.

the class BrowseController method renameRepositoryObject.

protected void renameRepositoryObject(final UIRepositoryObject object) throws XulException {
    XulPromptBox prompt = promptForName(object);
    prompt.addDialogCallback(new XulDialogCallback<String>() {

        public void onClose(XulComponent component, Status status, String value) {
            if (status == Status.ACCEPT) {
                try {
                    object.setName(value);
                } catch (Exception e) {
                    if (mainController == null || !mainController.handleLostRepository(e)) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }

        public void onError(XulComponent component, Throwable err) {
            throw new RuntimeException(err);
        }
    });
    prompt.open();
}
Also used : XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) XulComponent(org.pentaho.ui.xul.XulComponent) XulException(org.pentaho.ui.xul.XulException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) UIObjectCreationException(org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException) KettleException(org.pentaho.di.core.exception.KettleException)

Aggregations

XulPromptBox (org.pentaho.ui.xul.components.XulPromptBox)15 XulComponent (org.pentaho.ui.xul.XulComponent)6 XulException (org.pentaho.ui.xul.XulException)6 KettleException (org.pentaho.di.core.exception.KettleException)5 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)4 Test (org.junit.Test)2 ParameterGeneration (org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration)2 UIObjectCreationException (org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException)2 UIRepositoryObject (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject)2 XulMenuitem (org.pentaho.ui.xul.components.XulMenuitem)2 XulMessageBox (org.pentaho.ui.xul.components.XulMessageBox)2 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 FormPanel (com.google.gwt.user.client.ui.FormPanel)1 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)1 Label (com.google.gwt.user.client.ui.Label)1 Panel (com.google.gwt.user.client.ui.Panel)1 RadioButton (com.google.gwt.user.client.ui.RadioButton)1 RootPanel (com.google.gwt.user.client.ui.RootPanel)1 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)1 HttpStatus (org.apache.http.HttpStatus)1