Search in sources :

Example 11 with XulComponent

use of org.pentaho.ui.xul.XulComponent 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)

Example 12 with XulComponent

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

the class SecurityController method removeUser.

/**
 * removeUser method is called when user has click on a remove button in a user deck. It first displays a confirmation
 * message to the user and once the user selects ok, it remove the user
 *
 * @throws Exception
 */
public void removeUser() throws Exception {
    XulConfirmBox confirmBox = (XulConfirmBox) document.createElement("confirmbox");
    confirmBox.setTitle(BaseMessages.getString(PKG, "ConfirmDialog.Title"));
    confirmBox.setMessage(BaseMessages.getString(PKG, "RemoveUserConfirmDialog.Message"));
    confirmBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
    confirmBox.setCancelLabel(BaseMessages.getString(PKG, "Dialog.Cancel"));
    confirmBox.addDialogCallback(new XulDialogCallback<Object>() {

        public void onClose(XulComponent sender, Status returnCode, Object retVal) {
            if (returnCode == Status.ACCEPT) {
                if (service != null) {
                    if (security != null && security.getSelectedUser() != null) {
                        try {
                            service.delUser(security.getSelectedUser().getName());
                            security.removeUser(security.getSelectedUser().getName());
                        } catch (Throwable th) {
                            if (mainController == null || !mainController.handleLostRepository(th)) {
                                messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
                                messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
                                messageBox.setMessage(BaseMessages.getString(PKG, "RemoveUser.UnableToRemoveUser", th.getLocalizedMessage()));
                                messageBox.open();
                            }
                        }
                    } else {
                        messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
                        messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
                        messageBox.setMessage(BaseMessages.getString(PKG, "RemoveUser.NoUserSelected"));
                        messageBox.open();
                    }
                }
            }
        }

        public void onError(XulComponent sender, Throwable t) {
            if (mainController == null || !mainController.handleLostRepository(t)) {
                messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
                messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
                messageBox.setMessage(BaseMessages.getString(PKG, "RemoveUser.UnableToRemoveUser", t.getLocalizedMessage()));
                messageBox.open();
            }
        }
    });
    confirmBox.open();
}
Also used : XulConfirmBox(org.pentaho.ui.xul.components.XulConfirmBox) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 13 with XulComponent

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

the class AbstractGraph method dispose.

public void dispose() {
    super.dispose();
    List<XulComponent> pops = xulDomContainer.getDocumentRoot().getElementsByTagName("menupopup");
    for (XulComponent pop : pops) {
        ((MenuManager) pop.getManagedObject()).dispose();
    }
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 14 with XulComponent

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

the class RepositoriesHelper method deleteRepository.

public void deleteRepository() {
    try {
        XulConfirmBox confirmBox = (XulConfirmBox) document.createElement("confirmbox");
        final RepositoryMeta repositoryMeta = input.searchRepository(model.getSelectedRepository().getName());
        if (repositoryMeta != null) {
            confirmBox.setTitle(BaseMessages.getString(PKG, "RepositoryLogin.ConfirmDeleteRepositoryDialog.Title"));
            confirmBox.setMessage(BaseMessages.getString(PKG, "RepositoryLogin.ConfirmDeleteRepositoryDialog.Message"));
            confirmBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
            confirmBox.setCancelLabel(BaseMessages.getString(PKG, "Dialog.Cancel"));
            confirmBox.addDialogCallback(new XulDialogCallback<Object>() {

                public void onClose(XulComponent sender, Status returnCode, Object retVal) {
                    if (returnCode == Status.ACCEPT) {
                        int idx = input.indexOfRepository(repositoryMeta);
                        input.removeRepository(idx);
                        fillRepositories();
                        writeData();
                    }
                }

                public void onError(XulComponent sender, Throwable t) {
                    log.logDetailed(BaseMessages.getString(PKG, "RepositoryLogin.UnableToDeleteRepository", t.getLocalizedMessage()));
                    new ErrorDialog(shell, BaseMessages.getString(PKG, "Dialog.Error"), BaseMessages.getString(PKG, "RepositoryLogin.UnableToDeleteRepository", t.getLocalizedMessage()), t);
                }
            });
            confirmBox.open();
        }
    } catch (Exception e) {
        log.logDetailed(BaseMessages.getString(PKG, "RepositoryLogin.UnableToDeleteRepository", e.getLocalizedMessage()));
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Dialog.Error"), BaseMessages.getString(PKG, "RepositoryLogin.UnableToDeleteRepository", e.getLocalizedMessage()), e);
    }
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) XulConfirmBox(org.pentaho.ui.xul.components.XulConfirmBox) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) XulComponent(org.pentaho.ui.xul.XulComponent) KettleException(org.pentaho.di.core.exception.KettleException) KettleSecurityException(org.pentaho.di.core.exception.KettleSecurityException)

Example 15 with XulComponent

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

the class Spoon method removeMenuItem.

public void removeMenuItem(String itemid, boolean removeTrailingSeparators) {
    XulMenuitem item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById(itemid);
    if (item != null) {
        XulComponent menu = item.getParent();
        item.getParent().removeChild(item);
        if (removeTrailingSeparators) {
            List<XulComponent> children = menu.getChildNodes();
            if (children.size() > 0) {
                XulComponent lastMenuItem = children.get(children.size() - 1);
                if (lastMenuItem instanceof XulMenuseparator) {
                    menu.removeChild(lastMenuItem);
                    // the menu separators seem to not be modeled as individual objects in XUL
                    try {
                        Menu swtm = (Menu) menu.getManagedObject();
                        swtm.getItems()[swtm.getItemCount() - 1].dispose();
                    } catch (Throwable t) {
                        LogChannel.GENERAL.logError("Error removing XUL menu item", t);
                    }
                }
            }
        }
    } else {
        log.logError("Could not find menu item with id " + itemid + " to remove from Spoon menu");
    }
}
Also used : XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) Menu(org.eclipse.swt.widgets.Menu) XulComponent(org.pentaho.ui.xul.XulComponent) XulMenuseparator(org.pentaho.ui.xul.components.XulMenuseparator)

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