Search in sources :

Example 26 with ErrorDialog

use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.

the class RepositoryExplorerDialog method renameUser.

public boolean renameUser(String name, String newname) {
    boolean retval = false;
    try {
        if (Utils.isEmpty(newname)) {
            throw new KettleException(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Exception.NameCanNotBeEmpty"));
        }
        if (!name.equals(newname)) {
            ObjectId id = securityManager.getUserID(name);
            if (id != null) {
                // System.out.println("Renaming user ["+name+"] with ID = "+id);
                securityManager.renameUser(id, newname);
                retval = true;
            } else {
                MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.User.Rename.ErrorFinding.Message1") + name + "]" + Const.CR + BaseMessages.getString(PKG, "RepositoryExplorerDialog.User.Rename.ErrorFinding.Message2"));
                mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.User.Rename.ErrorFinding.Title"));
                mb.open();
            }
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.User.Rename.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.User.Rename.UnexpectedError.Message") + name + "]", e);
    }
    return retval;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ObjectId(org.pentaho.di.repository.ObjectId) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 27 with ErrorDialog

use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.

the class SelectDirectoryDialog method open.

@SuppressWarnings("deprecation")
public RepositoryDirectoryInterface open() {
    dircolor = GUIResource.getInstance().getColorDirectory();
    Shell parent = getParent();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageSpoon());
    shell.setText(BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.Main.Title"));
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    // Tree
    wTree = new Tree(shell, SWT.SINGLE | SWT.BORDER);
    props.setLook(wTree);
    try {
        if (rep instanceof RepositoryExtended) {
            RepositoryExtended repositoryExtended = (RepositoryExtended) this.rep;
            repositoryTree = repositoryExtended.loadRepositoryDirectoryTree("/", null, -1, BooleanUtils.isTrue(repositoryExtended.getUserInfo().isAdmin()), true, false);
        } else {
            repositoryTree = this.rep.loadRepositoryDirectoryTree();
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.ErrorRefreshingDirectoryTree.Title"), BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.ErrorRefreshingDirectoryTree.Message"), e);
        return null;
    }
    if (!getData()) {
        return null;
    }
    // Buttons
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wRefresh = new Button(shell, SWT.PUSH);
    wRefresh.setText(BaseMessages.getString(PKG, "System.Button.Refresh"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    FormData fdTree = new FormData();
    FormData fdOK = new FormData();
    FormData fdRefresh = new FormData();
    FormData fdCancel = new FormData();
    int margin = 10;
    // To the right of the label
    fdTree.left = new FormAttachment(0, 0);
    fdTree.top = new FormAttachment(0, 0);
    fdTree.right = new FormAttachment(100, 0);
    fdTree.bottom = new FormAttachment(100, -50);
    wTree.setLayoutData(fdTree);
    fdOK.left = new FormAttachment(wTree, 0, SWT.CENTER);
    fdOK.bottom = new FormAttachment(100, -margin);
    wOK.setLayoutData(fdOK);
    fdRefresh.left = new FormAttachment(wOK, 10);
    fdRefresh.bottom = new FormAttachment(100, -margin);
    wRefresh.setLayoutData(fdRefresh);
    fdCancel.left = new FormAttachment(wRefresh, 10);
    fdCancel.bottom = new FormAttachment(100, -margin);
    wCancel.setLayoutData(fdCancel);
    // Add listeners
    wCancel.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            dispose();
        }
    });
    // Add listeners
    wOK.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            handleOK();
        }
    });
    wTree.addSelectionListener(new SelectionAdapter() {

        private String getSelectedPath(SelectionEvent selectionEvent) {
            TreeItem treeItem = (TreeItem) selectionEvent.item;
            String path;
            if (treeItem.getParentItem() == null) {
                path = treeItem.getText();
            } else {
                path = ConstUI.getTreePath(treeItem, 0);
            }
            return path;
        }

        private boolean isSelectedPathRestricted(SelectionEvent selectionEvent) {
            String path = getSelectedPath(selectionEvent);
            boolean isRestricted = isRestrictedPath(path);
            return isRestricted;
        }

        public void widgetDefaultSelected(SelectionEvent selectionEvent) {
            if (isSelectedPathRestricted(selectionEvent)) {
                return;
            }
            handleOK();
        }

        public void widgetSelected(SelectionEvent selectionEvent) {
            boolean restricted = isSelectedPathRestricted(selectionEvent);
            wOK.setEnabled(!restricted);
        }
    });
    wRefresh.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            getData();
        }
    });
    wTree.addMenuDetectListener(new MenuDetectListener() {

        public void menuDetected(MenuDetectEvent e) {
            setTreeMenu();
        }
    });
    BaseStepDialog.setSize(shell);
    shell.open();
    Display display = parent.getDisplay();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return selection;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) KettleException(org.pentaho.di.core.exception.KettleException) Listener(org.eclipse.swt.widgets.Listener) MenuDetectListener(org.eclipse.swt.events.MenuDetectListener) TreeItem(org.eclipse.swt.widgets.TreeItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) MenuDetectEvent(org.eclipse.swt.events.MenuDetectEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) Event(org.eclipse.swt.widgets.Event) MenuDetectEvent(org.eclipse.swt.events.MenuDetectEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuDetectListener(org.eclipse.swt.events.MenuDetectListener) RepositoryExtended(org.pentaho.di.repository.RepositoryExtended) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display)

Example 28 with ErrorDialog

use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.

the class JobEntryTransDialog method getByReferenceData.

private void getByReferenceData(ObjectId transObjectId) {
    try {
        RepositoryObject transInf = rep.getObjectInformation(transObjectId, RepositoryObjectType.TRANSFORMATION);
        String path = DialogUtils.getPath(jobMeta.getRepositoryDirectory().getPath(), transInf.getRepositoryDirectory().getPath());
        String fullPath = Const.NVL(path, "") + "/" + Const.NVL(transInf.getName(), "");
        wPath.setText(fullPath);
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "JobEntryTransDialog.Exception.UnableToReferenceObjectId.Title"), BaseMessages.getString(PKG, "JobEntryTransDialog.Exception.UnableToReferenceObjectId.Message"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObject(org.pentaho.di.repository.RepositoryObject) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog)

Example 29 with ErrorDialog

use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.

the class RepositoryExplorerDialog method editSlaveServer.

public void editSlaveServer(String slaveName) {
    try {
        ObjectId id = rep.getSlaveID(slaveName);
        // Load the last version
        SlaveServer slaveServer = rep.loadSlaveServer(id, null);
        SlaveServerDialog dd = new SlaveServerDialog(shell, slaveServer);
        if (dd.open()) {
            rep.insertLogEntry("Updating slave server '" + slaveServer.getName() + "'");
            rep.save(slaveServer, Const.VERSION_COMMENT_EDIT_VERSION, null);
            if (!slaveName.equalsIgnoreCase(slaveServer.getName())) {
                refreshTree();
            }
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Edit.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Edit.UnexpectedError.Message") + slaveName + "]", e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ObjectId(org.pentaho.di.repository.ObjectId) SlaveServerDialog(org.pentaho.di.ui.cluster.dialog.SlaveServerDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SlaveServer(org.pentaho.di.cluster.SlaveServer)

Example 30 with ErrorDialog

use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.

the class RepositoryExplorerDialog method renameJob.

public boolean renameJob(String name, RepositoryDirectoryInterface repdir, String newname) {
    boolean retval = false;
    try {
        if (Utils.isEmpty(newname)) {
            throw new KettleException(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Exception.NameCanNotBeEmpty"));
        }
        if (!name.equals(newname)) {
            ObjectId id = rep.getJobId(name, repdir);
            if (id != null) {
                // System.out.println("Renaming transformation ["+name+"] with ID = "+id);
                String comment = BaseMessages.getString(REPOSITORY_PKG, "Repository.Rename", name, newname);
                rep.renameJob(id, comment, repdir, newname);
                retval = true;
            } else {
                MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Rename.ErrorFinding.Message1") + name + "]" + Const.CR + BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Rename.ErrorFinding.Message2"));
                mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Rename.ErrorFinding.Title"));
                mb.open();
            }
        }
    } catch (KettleException dbe) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Rename.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Rename.UnexpectedError.Message") + name + "]", dbe);
    }
    return retval;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ObjectId(org.pentaho.di.repository.ObjectId) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)527 KettleException (org.pentaho.di.core.exception.KettleException)440 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)178 MessageBox (org.eclipse.swt.widgets.MessageBox)118 TableItem (org.eclipse.swt.widgets.TableItem)97 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)76 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)63 TransMeta (org.pentaho.di.trans.TransMeta)48 Shell (org.eclipse.swt.widgets.Shell)46 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)46 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)44 EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)44 ArrayList (java.util.ArrayList)43 TableItemInsertListener (org.pentaho.di.ui.trans.step.TableItemInsertListener)43 EnterSelectionDialog (org.pentaho.di.ui.core.dialog.EnterSelectionDialog)42 SelectionEvent (org.eclipse.swt.events.SelectionEvent)40 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)39 StepMeta (org.pentaho.di.trans.step.StepMeta)38 FormData (org.eclipse.swt.layout.FormData)37 FormLayout (org.eclipse.swt.layout.FormLayout)37